| Conditions | 18 |
| Paths | 1728 |
| Total Lines | 314 |
| Code Lines | 239 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 50 | public function __construct($db) |
||
| 51 | { |
||
| 52 | global $conf; |
||
| 53 | |||
| 54 | $this->db = $db; |
||
| 55 | $this->numero = 400; |
||
| 56 | |||
| 57 | $this->family = "projects"; |
||
| 58 | $this->module_position = '14'; |
||
| 59 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
| 60 | $this->name = preg_replace('/^mod/i', '', get_only_class($this)); |
||
| 61 | $this->description = "Gestion des projects"; |
||
| 62 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
||
| 63 | $this->version = 'dolibarr'; |
||
| 64 | |||
| 65 | $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
||
| 66 | $this->config_page_url = array("project.php@projet"); |
||
| 67 | $this->picto = 'project'; |
||
| 68 | |||
| 69 | // Data directories to create when module is enabled |
||
| 70 | $this->dirs = array("/projet/temp"); |
||
| 71 | |||
| 72 | // Dependencies |
||
| 73 | $this->hidden = false; // A condition to hide module |
||
| 74 | $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
||
| 75 | $this->requiredby = array('modEventOrganization'); // List of module ids to disable if this one is disabled |
||
| 76 | $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
||
| 77 | $this->phpmin = array(7, 0); // Minimum version of PHP required by module |
||
| 78 | $this->langfiles = array('projects'); |
||
| 79 | |||
| 80 | // Constants |
||
| 81 | $this->const = array(); |
||
| 82 | $r = 0; |
||
| 83 | |||
| 84 | $this->const[$r][0] = "PROJECT_ADDON_PDF"; |
||
| 85 | $this->const[$r][1] = "chaine"; |
||
| 86 | $this->const[$r][2] = "baleine"; |
||
| 87 | $this->const[$r][3] = 'Name of PDF/ODT project manager class'; |
||
| 88 | $this->const[$r][4] = 0; |
||
| 89 | $r++; |
||
| 90 | |||
| 91 | $this->const[$r][0] = "PROJECT_ADDON"; |
||
| 92 | $this->const[$r][1] = "chaine"; |
||
| 93 | $this->const[$r][2] = "mod_project_simple"; |
||
| 94 | $this->const[$r][3] = 'Name of Numbering Rule project manager class'; |
||
| 95 | $this->const[$r][4] = 0; |
||
| 96 | $r++; |
||
| 97 | |||
| 98 | $this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH"; |
||
| 99 | $this->const[$r][1] = "chaine"; |
||
| 100 | $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects"; |
||
| 101 | $this->const[$r][3] = ""; |
||
| 102 | $this->const[$r][4] = 0; |
||
| 103 | $r++; |
||
| 104 | |||
| 105 | $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF"; |
||
| 106 | $this->const[$r][1] = "chaine"; |
||
| 107 | $this->const[$r][2] = ""; |
||
| 108 | $this->const[$r][3] = 'Name of PDF/ODT tasks manager class'; |
||
| 109 | $this->const[$r][4] = 0; |
||
| 110 | $r++; |
||
| 111 | |||
| 112 | $this->const[$r][0] = "PROJECT_TASK_ADDON"; |
||
| 113 | $this->const[$r][1] = "chaine"; |
||
| 114 | $this->const[$r][2] = "mod_task_simple"; |
||
| 115 | $this->const[$r][3] = 'Name of Numbering Rule task manager class'; |
||
| 116 | $this->const[$r][4] = 0; |
||
| 117 | $r++; |
||
| 118 | |||
| 119 | $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH"; |
||
| 120 | $this->const[$r][1] = "chaine"; |
||
| 121 | $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks"; |
||
| 122 | $this->const[$r][3] = ""; |
||
| 123 | $this->const[$r][4] = 0; |
||
| 124 | $r++; |
||
| 125 | |||
| 126 | $this->const[$r][0] = "PROJECT_USE_OPPORTUNITIES"; |
||
| 127 | $this->const[$r][1] = "chaine"; |
||
| 128 | $this->const[$r][2] = "1"; |
||
| 129 | $this->const[$r][3] = ""; |
||
| 130 | $this->const[$r][4] = 0; |
||
| 131 | $r++; |
||
| 132 | |||
| 133 | // Boxes |
||
| 134 | $this->boxes = array( |
||
| 135 | 0 => array('file' => 'box_project.php', 'enabledbydefaulton' => 'Home'), // open projects |
||
| 136 | 1 => array('file' => 'box_project_opportunities.php', 'enabledbydefaulton' => 'Home'), // open opportunities |
||
| 137 | 2 => array('file' => 'box_task.php', 'enabledbydefaulton' => 'Home'), |
||
| 138 | 3 => array('file' => 'box_validated_projects.php', 'enabledbydefaulton' => 'Home'), // task without timespent |
||
| 139 | 4 => array('file' => 'box_funnel_of_prospection.php', 'enabledbydefaulton' => 'Home'), |
||
| 140 | ); |
||
| 141 | // Cronjobs |
||
| 142 | $this->cronjobs[] = array( |
||
| 143 | 'label' => 'WeeklyWorkingHoursReport', |
||
| 144 | 'jobtype' => 'method', |
||
| 145 | 'class' => 'projet/class/project.class.php', |
||
| 146 | 'objectname' => 'Project', |
||
| 147 | 'method' => 'createWeeklyReport', |
||
| 148 | 'parameters' => '', |
||
| 149 | 'comment' => 'Generates and sends a weekly report on time worked', |
||
| 150 | 'frequency' => 1, |
||
| 151 | 'unitfrequency' => 86400 * 7, |
||
| 152 | 'status' => 0, |
||
| 153 | 'test' => '$conf->projet->enabled', |
||
| 154 | ); |
||
| 155 | // Permissions |
||
| 156 | $this->rights = array(); |
||
| 157 | $this->rights_class = 'projet'; |
||
| 158 | $r = 0; |
||
| 159 | |||
| 160 | $r++; |
||
| 161 | $this->rights[$r][0] = 41; // id de la permission |
||
| 162 | $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission |
||
| 163 | $this->rights[$r][2] = 'r'; // type de la permission (deprecated) |
||
| 164 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 165 | $this->rights[$r][4] = 'lire'; |
||
| 166 | |||
| 167 | $r++; |
||
| 168 | $this->rights[$r][0] = 42; // id de la permission |
||
| 169 | $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission |
||
| 170 | $this->rights[$r][2] = 'w'; // type de la permission (deprecated) |
||
| 171 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 172 | $this->rights[$r][4] = 'creer'; |
||
| 173 | |||
| 174 | $r++; |
||
| 175 | $this->rights[$r][0] = 44; // id de la permission |
||
| 176 | $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission |
||
| 177 | $this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
||
| 178 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 179 | $this->rights[$r][4] = 'supprimer'; |
||
| 180 | |||
| 181 | $r++; |
||
| 182 | $this->rights[$r][0] = 45; // id de la permission |
||
| 183 | $this->rights[$r][1] = "Export projects"; // libelle de la permission |
||
| 184 | $this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
||
| 185 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 186 | $this->rights[$r][4] = 'export'; |
||
| 187 | |||
| 188 | $r++; |
||
| 189 | $this->rights[$r][0] = 141; // id de la permission |
||
| 190 | $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission |
||
| 191 | $this->rights[$r][2] = 'r'; // type de la permission (deprecated) |
||
| 192 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 193 | $this->rights[$r][4] = 'all'; |
||
| 194 | $this->rights[$r][5] = 'lire'; |
||
| 195 | |||
| 196 | $r++; |
||
| 197 | $this->rights[$r][0] = 142; // id de la permission |
||
| 198 | $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission |
||
| 199 | $this->rights[$r][2] = 'w'; // type de la permission (deprecated) |
||
| 200 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 201 | $this->rights[$r][4] = 'all'; |
||
| 202 | $this->rights[$r][5] = 'creer'; |
||
| 203 | |||
| 204 | $r++; |
||
| 205 | $this->rights[$r][0] = 144; // id de la permission |
||
| 206 | $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission |
||
| 207 | $this->rights[$r][2] = 'd'; // type de la permission (deprecated) |
||
| 208 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 209 | $this->rights[$r][4] = 'all'; |
||
| 210 | $this->rights[$r][5] = 'supprimer'; |
||
| 211 | |||
| 212 | $r++; |
||
| 213 | $this->rights[$r][0] = 145; // id de la permission |
||
| 214 | $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission |
||
| 215 | $this->rights[$r][2] = 'w'; // type de la permission (deprecated) |
||
| 216 | $this->rights[$r][3] = 0; // La permission est-elle une permission par default |
||
| 217 | $this->rights[$r][4] = 'time'; |
||
| 218 | |||
| 219 | // Menus |
||
| 220 | //------- |
||
| 221 | $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
||
| 222 | |||
| 223 | |||
| 224 | // Exports |
||
| 225 | //-------- |
||
| 226 | $r = 1; |
||
| 227 | |||
| 228 | $this->export_code[$r] = $this->rights_class . '_' . $r; |
||
| 229 | $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
||
| 230 | $this->export_permission[$r] = array(array("projet", "export")); |
||
| 231 | $this->export_dependencies_array[$r] = array('projecttask' => 'pt.rowid', 'task_time' => 'ptt.rowid'); |
||
| 232 | |||
| 233 | $this->export_TypeFields_array[$r] = array( |
||
| 234 | 's.rowid' => "Numeric", 's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text', 's.fk_pays' => 'List:c_country:label', |
||
| 235 | 's.phone' => 'Text', 's.email' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', 's.idprof4' => 'Text', 's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', |
||
| 236 | 'p.rowid' => "Numeric", 'p.ref' => "Text", 'p.title' => "Text", |
||
| 237 | 'p.usage_opportunity' => 'Boolean', 'p.usage_task' => 'Boolean', 'p.usage_bill_time' => 'Boolean', |
||
| 238 | 'p.datec' => "Date", 'p.dateo' => "Date", 'p.datee' => "Date", 'p.fk_statut' => 'Status', 'cls.code' => "Text", 'p.opp_percent' => 'Numeric', 'p.opp_amount' => 'Numeric', 'p.description' => "Text", 'p.entity' => 'Numeric', 'p.budget_amount' => 'Numeric', |
||
| 239 | 'pt.rowid' => 'Numeric', 'pt.ref' => 'Text', 'pt.label' => 'Text', 'pt.dateo' => "Date", 'pt.datee' => "Date", 'pt.duration_effective' => "Duree", 'pt.planned_workload' => "Numeric", 'pt.progress' => "Numeric", 'pt.description' => "Text", |
||
| 240 | 'ptt.rowid' => 'Numeric', 'ptt.element_date' => 'Date', 'ptt.element_duration' => "Duree", 'ptt.fk_user' => "FormSelect:select_dolusers", 'ptt.note' => "Text" |
||
| 241 | ); |
||
| 242 | $this->export_entities_array[$r] = array( |
||
| 243 | 's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company', 's.fk_pays' => 'company', |
||
| 244 | 's.phone' => 'company', 's.email' => 'company', 's.siren' => 'company', 's.siret' => 'company', 's.ape' => 'company', 's.idprof4' => 'company', 's.code_compta' => 'company', 's.code_compta_fournisseur' => 'company' |
||
| 245 | ); |
||
| 246 | $this->export_fields_array[$r] = array( |
||
| 247 | 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', 's.fk_pays' => 'Country', |
||
| 248 | 's.phone' => 'Phone', 's.email' => 'Email', 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', |
||
| 249 | 'p.rowid' => "ProjectId", 'p.ref' => "RefProject", 'p.title' => 'ProjectLabel', |
||
| 250 | 'p.usage_opportunity' => 'ProjectFollowOpportunity', 'p.usage_task' => 'ProjectFollowTasks', 'p.usage_bill_time' => 'BillTime', |
||
| 251 | 'p.datec' => "DateCreation", 'p.dateo' => "DateStart", 'p.datee' => "DateEnd", 'p.fk_statut' => 'ProjectStatus', 'cls.code' => 'OpportunityStatus', 'p.opp_percent' => 'OpportunityProbability', 'p.opp_amount' => 'OpportunityAmount', 'p.budget_amount' => 'Budget', 'p.description' => "Description" |
||
| 252 | ); |
||
| 253 | // Add multicompany field |
||
| 254 | if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) { |
||
| 255 | $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1 |
||
| 256 | if (isModEnabled('multicompany') && $nbofallowedentities > 1) { |
||
| 257 | $this->export_fields_array[$r] += array('p.entity' => 'Entity'); |
||
| 258 | } |
||
| 259 | } |
||
| 260 | if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { |
||
| 261 | unset($this->export_fields_array[$r]['p.opp_percent']); |
||
| 262 | unset($this->export_fields_array[$r]['p.opp_amount']); |
||
| 263 | unset($this->export_fields_array[$r]['cls.code']); |
||
| 264 | } |
||
| 265 | |||
| 266 | // Add fields for project |
||
| 267 | $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array()); |
||
| 268 | // Add extra fields for project |
||
| 269 | $keyforselect = 'projet'; |
||
| 270 | $keyforelement = 'project'; |
||
| 271 | $keyforaliasextra = 'extra'; |
||
| 272 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 273 | // Add fields for tasks |
||
| 274 | $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid' => 'TaskId', 'pt.ref' => 'RefTask', 'pt.label' => 'LabelTask', 'pt.dateo' => "TaskDateStart", 'pt.datee' => "TaskDateEnd", 'pt.duration_effective' => "DurationEffective", 'pt.planned_workload' => "PlannedWorkload", 'pt.progress' => "Progress", 'pt.description' => "TaskDescription")); |
||
| 275 | $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid' => 'projecttask', 'pt.ref' => 'projecttask', 'pt.label' => 'projecttask', 'pt.dateo' => "projecttask", 'pt.datee' => "projecttask", 'pt.duration_effective' => "projecttask", 'pt.planned_workload' => "projecttask", 'pt.progress' => "projecttask", 'pt.description' => "projecttask")); |
||
| 276 | // Add extra fields for task |
||
| 277 | $keyforselect = 'projet_task'; |
||
| 278 | $keyforelement = 'projecttask'; |
||
| 279 | $keyforaliasextra = 'extra2'; |
||
| 280 | include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
||
| 281 | // End add extra fields |
||
| 282 | $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid' => 'IdTaskTime', 'ptt.element_date' => 'TaskTimeDate', 'ptt.element_duration' => "TimeSpent", 'ptt.fk_user' => "TaskTimeUser", 'ptt.note' => "TaskTimeNote")); |
||
| 283 | $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid' => 'task_time', 'ptt.element_date' => 'task_time', 'ptt.element_duration' => "task_time", 'ptt.fk_user' => "task_time", 'ptt.note' => "task_time")); |
||
| 284 | if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { |
||
| 285 | $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref' => "Billed")); |
||
| 286 | $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref' => "task_time")); |
||
| 287 | } |
||
| 288 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
||
| 289 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'projet as p'; |
||
| 290 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_extrafields as extra ON p.rowid = extra.fk_object'; |
||
| 291 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; |
||
| 292 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . "projet_task as pt ON p.rowid = pt.fk_projet"; |
||
| 293 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; |
||
| 294 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . "element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')"; |
||
| 295 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON p.fk_soc = s.rowid'; |
||
| 296 | if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { |
||
| 297 | $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture as f ON ptt.invoice_id = f.rowid'; |
||
| 298 | } |
||
| 299 | $this->export_sql_end[$r] .= " WHERE p.entity IN (" . getEntity('project') . ")"; |
||
| 300 | |||
| 301 | // Import project/opportunities |
||
| 302 | $r++; |
||
| 303 | $this->import_code[$r] = 'projects'; |
||
| 304 | $this->import_label[$r] = 'ImportDatasetProjects'; |
||
| 305 | $this->import_icon[$r] = 'project'; |
||
| 306 | $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
||
| 307 | $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX . 'projet', 'extra' => MAIN_DB_PREFIX . 'projet_extrafields'); // List of tables to insert into (insert done in same order) |
||
| 308 | $this->import_fields_array[$r] = array('t.ref' => 'ProjectRef*', 't.title' => 'Label*', 't.description' => "Description", 't.fk_soc' => 'ThirdPartyName', 't.public' => "Public", 't.fk_statut' => "Status"); |
||
| 309 | $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('t.fk_opp_status' => "OpportunityStatus", 't.opp_percent' => "OpportunityProbability", 't.opp_amount' => "OpportunityAmount", 't.note_public' => "NotePublic", 't.note_private' => "NotePrivate", 't.budget_amount' => "Budget", 't.dateo' => "DateStart", 't.datee' => "DateEnd")); |
||
| 310 | // Add extra fields |
||
| 311 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0," . $conf->entity . ")"; |
||
| 312 | $resql = $this->db->query($sql); |
||
| 313 | if ($resql) { // This can fail when class is used on old database (during migration for example) |
||
| 314 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 315 | $fieldname = 'extra.' . $obj->name; |
||
| 316 | $fieldlabel = ucfirst($obj->label); |
||
| 317 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 318 | } |
||
| 319 | } |
||
| 320 | // End add extra fields |
||
| 321 | $this->import_fieldshidden_array[$r] = array('t.fk_user_creat' => 'user->id', 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'projet'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
||
| 322 | $this->import_convertvalue_array[$r] = array( |
||
| 323 | 't.ref' => array('rule' => 'getrefifauto', 'class' => (!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON), 'path' => "/core/modules/project/" . (!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON) . '.php'), |
||
| 324 | 't.fk_soc' => array( |
||
| 325 | 'rule' => 'fetchidfromref', |
||
| 326 | 'file' => '/societe/class/societe.class.php', |
||
| 327 | 'class' => 'Societe', |
||
| 328 | 'method' => 'fetch', |
||
| 329 | 'element' => 'ThirdParty' |
||
| 330 | ), |
||
| 331 | ); |
||
| 332 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
||
| 333 | $this->import_regex_array[$r] = array('t.dateo' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
||
| 334 | $this->import_examplevalues_array[$r] = array('t.fk_soc' => 'ThirdParty', 't.ref' => "auto or PJ2010-1234", 't.title' => "My project", 't.fk_statut' => '0,1 or 2', 't.datec' => '1972-10-10', 't.note_private' => "My private note", 't.note_public' => "My public note"); |
||
| 335 | |||
| 336 | // Import list of tasks |
||
| 337 | if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { |
||
| 338 | $r++; |
||
| 339 | $this->import_code[$r] = 'tasksofprojects'; |
||
| 340 | $this->import_label[$r] = 'ImportDatasetTasks'; |
||
| 341 | $this->import_icon[$r] = 'task'; |
||
| 342 | $this->import_entities_array[$r] = array('t.fk_projet' => 'project'); // We define here only fields that use another icon that the one defined into import_icon |
||
| 343 | $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX . 'projet_task', 'extra' => MAIN_DB_PREFIX . 'projet_task_extrafields'); // List of tables to insert into (insert done in same order) |
||
| 344 | $this->import_fields_array[$r] = array('t.fk_projet' => 'ProjectRef*', 't.ref' => 'RefTask*', 't.label' => 'LabelTask*', 't.dateo' => "DateStart", 't.datee' => "DateEnd", 't.planned_workload' => "PlannedWorkload", 't.progress' => "Progress", 't.note_private' => "NotePrivate", 't.note_public' => "NotePublic", 't.datec' => "DateCreation"); |
||
| 345 | // Add extra fields |
||
| 346 | $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0," . $conf->entity . ")"; |
||
| 347 | $resql = $this->db->query($sql); |
||
| 348 | if ($resql) { // This can fail when class is used on old database (during migration for example) |
||
| 349 | while ($obj = $this->db->fetch_object($resql)) { |
||
| 350 | $fieldname = 'extra.' . $obj->name; |
||
| 351 | $fieldlabel = ucfirst($obj->label); |
||
| 352 | $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
||
| 353 | } |
||
| 354 | } |
||
| 355 | // End add extra fields |
||
| 356 | $this->import_fieldshidden_array[$r] = array('t.fk_user_creat' => 'user->id', 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
||
| 357 | $this->import_convertvalue_array[$r] = array( |
||
| 358 | 't.fk_projet' => array('rule' => 'fetchidfromref', 'classfile' => '/projet/class/project.class.php', 'class' => 'Project', 'method' => 'fetch', 'element' => 'Project'), |
||
| 359 | 't.ref' => array('rule' => 'getrefifauto', 'class' => (!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON), 'path' => "/core/modules/project/task/" . (!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON) . '.php') |
||
| 360 | ); |
||
| 361 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
||
| 362 | $this->import_regex_array[$r] = array('t.dateo' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
||
| 363 | $this->import_examplevalues_array[$r] = array('t.fk_projet' => 'MyProjectRef', 't.ref' => "auto or TK2010-1234", 't.label' => "My task", 't.progress' => "0 (not started) to 100 (finished)", 't.datec' => '1972-10-10', 't.note_private' => "My private note", 't.note_public' => "My public note"); |
||
| 364 | } |
||
| 427 |