@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File with class to manage the numbering module Simple for project references |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | - public $prefix='TK'; |
|
40 | + public $prefix = 'TK'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string Error code (or message) |
44 | 44 | */ |
45 | - public $error=''; |
|
45 | + public $error = ''; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @var string |
49 | 49 | * @deprecated |
50 | 50 | * @see name |
51 | 51 | */ |
52 | - public $nom='Simple'; |
|
52 | + public $nom = 'Simple'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string name |
56 | 56 | */ |
57 | - public $name='Simple'; |
|
57 | + public $name = 'Simple'; |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function info() |
66 | 66 | { |
67 | 67 | global $langs; |
68 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
68 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -87,30 +87,30 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function canBeActivated() |
89 | 89 | { |
90 | - global $conf,$langs,$db; |
|
90 | + global $conf, $langs, $db; |
|
91 | 91 | |
92 | - $coyymm=''; $max=''; |
|
92 | + $coyymm = ''; $max = ''; |
|
93 | 93 | |
94 | - $posindice=8; |
|
95 | - $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max"; |
|
96 | - $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, "; |
|
97 | - $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid"; |
|
98 | - $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'"; |
|
99 | - $sql .= " AND project.entity = " . $conf->entity; |
|
100 | - $resql=$db->query($sql); |
|
94 | + $posindice = 8; |
|
95 | + $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
96 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, "; |
|
97 | + $sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid"; |
|
98 | + $sql .= " AND task.ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
99 | + $sql .= " AND project.entity = ".$conf->entity; |
|
100 | + $resql = $db->query($sql); |
|
101 | 101 | if ($resql) |
102 | 102 | { |
103 | 103 | $row = $db->fetch_row($resql); |
104 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
105 | 105 | } |
106 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
106 | + if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
107 | 107 | { |
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | 112 | $langs->load("errors"); |
113 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
113 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | } |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | * @param Task $object Object Task |
124 | 124 | * @return string Value if OK, 0 if KO |
125 | 125 | */ |
126 | - function getNextValue($objsoc,$object) |
|
126 | + function getNextValue($objsoc, $object) |
|
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | 130 | // D'abord on recupere la valeur max |
131 | - $posindice=8; |
|
131 | + $posindice = 8; |
|
132 | 132 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
133 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
134 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
133 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
134 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
135 | 135 | |
136 | - $resql=$db->query($sql); |
|
136 | + $resql = $db->query($sql); |
|
137 | 137 | if ($resql) |
138 | 138 | { |
139 | 139 | $obj = $db->fetch_object($resql); |
140 | 140 | if ($obj) $max = intval($obj->max); |
141 | - else $max=0; |
|
141 | + else $max = 0; |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | return -1; |
147 | 147 | } |
148 | 148 | |
149 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
149 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
150 | 150 | |
151 | 151 | //$yymm = strftime("%y%m",time()); |
152 | - $yymm = strftime("%y%m",$date); |
|
152 | + $yymm = strftime("%y%m", $date); |
|
153 | 153 | |
154 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | - else $num = sprintf("%04s",$max+1); |
|
154 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else $num = sprintf("%04s", $max + 1); |
|
156 | 156 | |
157 | 157 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
158 | 158 | return $this->prefix.$yymm."-".$num; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param Task $object Object task |
168 | 168 | * @return string Next not used reference |
169 | 169 | */ |
170 | - function task_get_num($objsoc=0,$object='') |
|
170 | + function task_get_num($objsoc = 0, $object = '') |
|
171 | 171 | { |
172 | - return $this->getNextValue($objsoc,$object); |
|
172 | + return $this->getNextValue($objsoc, $object); |
|
173 | 173 | } |
174 | 174 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Universal'; |
|
49 | + public $nom = 'Universal'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string name |
53 | 53 | */ |
54 | - public $name='Universal'; |
|
54 | + public $name = 'Universal'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -61,36 +61,36 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function info() |
63 | 63 | { |
64 | - global $conf,$langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | 66 | // Load translation files required by the page |
67 | - $langs->loadLangs(array("projects","admin")); |
|
67 | + $langs->loadLangs(array("projects", "admin")); |
|
68 | 68 | |
69 | 69 | $form = new Form($this->db); |
70 | 70 | |
71 | 71 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
72 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | - $texte.= '<input type="hidden" name="action" value="updateMaskTask">'; |
|
75 | - $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | - |
|
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
72 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | + $texte .= '<input type="hidden" name="action" value="updateMaskTask">'; |
|
75 | + $texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
76 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
77 | + |
|
78 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
83 | 83 | |
84 | 84 | // Parametrage du prefix |
85 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
87 | 87 | |
88 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
89 | 89 | |
90 | - $texte.= '</tr>'; |
|
90 | + $texte .= '</tr>'; |
|
91 | 91 | |
92 | - $texte.= '</table>'; |
|
93 | - $texte.= '</form>'; |
|
92 | + $texte .= '</table>'; |
|
93 | + $texte .= '</form>'; |
|
94 | 94 | |
95 | 95 | return $texte; |
96 | 96 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getExample() |
104 | 104 | { |
105 | - global $conf,$langs,$mysoc; |
|
105 | + global $conf, $langs, $mysoc; |
|
106 | 106 | |
107 | - $old_code_client=$mysoc->code_client; |
|
108 | - $mysoc->code_client='CCCCCCCCCC'; |
|
109 | - $numExample = $this->getNextValue($mysoc,''); |
|
110 | - $mysoc->code_client=$old_code_client; |
|
107 | + $old_code_client = $mysoc->code_client; |
|
108 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
109 | + $numExample = $this->getNextValue($mysoc, ''); |
|
110 | + $mysoc->code_client = $old_code_client; |
|
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * @param Task $object Object task |
124 | 124 | * @return string Value if OK, 0 if KO |
125 | 125 | */ |
126 | - function getNextValue($objsoc,$object) |
|
126 | + function getNextValue($objsoc, $object) |
|
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
131 | 131 | |
132 | 132 | // On defini critere recherche compteur |
133 | - $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
133 | + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
134 | 134 | |
135 | - if (! $mask) |
|
135 | + if (!$mask) |
|
136 | 136 | { |
137 | - $this->error='NotConfigured'; |
|
137 | + $this->error = 'NotConfigured'; |
|
138 | 138 | return 0; |
139 | 139 | } |
140 | 140 | |
141 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
142 | - $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date); |
|
141 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
142 | + $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
143 | 143 | |
144 | 144 | return $numFinal; |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param Task $object Object task |
154 | 154 | * @return string Next not used reference |
155 | 155 | */ |
156 | - function project_get_num($objsoc=0,$object='') |
|
156 | + function project_get_num($objsoc = 0, $object = '') |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | 159 | return $this->getNextValue($objsoc, $object); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var string Error code (or message) |
37 | 37 | */ |
38 | - public $error=''; |
|
38 | + public $error = ''; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * @param integer $maxfilenamelength Max length of value to show |
47 | 47 | * @return array List of templates |
48 | 48 | */ |
49 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
49 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
50 | 50 | { |
51 | 51 | // phpcs:enable |
52 | 52 | global $conf; |
53 | 53 | |
54 | - $type='project_task'; |
|
55 | - $liste=array(); |
|
54 | + $type = 'project_task'; |
|
55 | + $liste = array(); |
|
56 | 56 | |
57 | 57 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
58 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
58 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
59 | 59 | |
60 | 60 | return $liste; |
61 | 61 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * @var string Error code (or message) |
73 | 73 | */ |
74 | - public $error=''; |
|
74 | + public $error = ''; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Return if a module can be used or not |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Universal'; |
|
49 | + public $nom = 'Universal'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Universal'; |
|
54 | + public $name = 'Universal'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -64,33 +64,33 @@ discard block |
||
64 | 64 | global $conf, $langs; |
65 | 65 | |
66 | 66 | // Load translation files required by the page |
67 | - $langs->loadLangs(array("projects","admin")); |
|
67 | + $langs->loadLangs(array("projects", "admin")); |
|
68 | 68 | |
69 | 69 | $form = new Form($this->db); |
70 | 70 | |
71 | 71 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
72 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | - $texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | - |
|
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
72 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | + $texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
76 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
77 | + |
|
78 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
83 | 83 | |
84 | 84 | // Parametrage du prefix |
85 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
87 | 87 | |
88 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
89 | 89 | |
90 | - $texte.= '</tr>'; |
|
90 | + $texte .= '</tr>'; |
|
91 | 91 | |
92 | - $texte.= '</table>'; |
|
93 | - $texte.= '</form>'; |
|
92 | + $texte .= '</table>'; |
|
93 | + $texte .= '</form>'; |
|
94 | 94 | |
95 | 95 | return $texte; |
96 | 96 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getExample() |
104 | 104 | { |
105 | - global $conf,$langs,$mysoc; |
|
105 | + global $conf, $langs, $mysoc; |
|
106 | 106 | |
107 | - $old_code_client=$mysoc->code_client; |
|
108 | - $mysoc->code_client='CCCCCCCCCC'; |
|
109 | - $numExample = $this->getNextValue($mysoc,''); |
|
110 | - $mysoc->code_client=$old_code_client; |
|
107 | + $old_code_client = $mysoc->code_client; |
|
108 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
109 | + $numExample = $this->getNextValue($mysoc, ''); |
|
110 | + $mysoc->code_client = $old_code_client; |
|
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function getNextValue($objsoc, $project) |
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
131 | 131 | |
132 | 132 | // On defini critere recherche compteur |
133 | - $mask=$conf->global->PROJECT_UNIVERSAL_MASK; |
|
133 | + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; |
|
134 | 134 | |
135 | - if (! $mask) |
|
135 | + if (!$mask) |
|
136 | 136 | { |
137 | - $this->error='NotConfigured'; |
|
137 | + $this->error = 'NotConfigured'; |
|
138 | 138 | return 0; |
139 | 139 | } |
140 | 140 | |
141 | - $date=empty($project->date_c)?dol_now():$project->date_c; |
|
142 | - $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
141 | + $date = empty($project->date_c) ?dol_now() : $project->date_c; |
|
142 | + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
143 | 143 | |
144 | 144 | return $numFinal; |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param Project $project Object project |
154 | 154 | * @return string Next not used reference |
155 | 155 | */ |
156 | - function project_get_num($objsoc=0, $project='') |
|
156 | + function project_get_num($objsoc = 0, $project = '') |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | 159 | return $this->getNextValue($objsoc, $project); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module externalrss |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->family = "technic"; |
49 | 49 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
50 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
51 | 51 | $this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr"; |
52 | 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
53 | 53 | $this->version = 'dolibarr'; |
54 | 54 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
55 | - $this->picto='rss'; |
|
55 | + $this->picto = 'rss'; |
|
56 | 56 | |
57 | 57 | // Data directories to create when module is enabled |
58 | 58 | $this->dirs = array("/externalrss/temp"); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // Dependencies |
64 | 64 | $this->depends = array(); |
65 | 65 | $this->requiredby = array(); |
66 | - $this->phpmin = array(4,2,0); |
|
66 | + $this->phpmin = array(4, 2, 0); |
|
67 | 67 | $this->phpmax = array(); |
68 | 68 | |
69 | 69 | // Constants |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @param string $options Options when enabling module ('', 'noboxes') |
87 | 87 | * @return int 1 if OK, 0 if KO |
88 | 88 | */ |
89 | - function init($options='') |
|
89 | + function init($options = '') |
|
90 | 90 | { |
91 | 91 | global $conf; |
92 | 92 | |
93 | 93 | $sql = array(); |
94 | 94 | |
95 | 95 | // Recherche configuration de boites |
96 | - $this->boxes=array(); |
|
97 | - $sql="select name, value from ".MAIN_DB_PREFIX."const"; |
|
98 | - $sql.= " WHERE name like 'EXTERNAL_RSS_TITLE_%'"; |
|
99 | - $sql.= " AND entity = ".$conf->entity; |
|
100 | - $result=$this->db->query($sql); |
|
96 | + $this->boxes = array(); |
|
97 | + $sql = "select name, value from ".MAIN_DB_PREFIX."const"; |
|
98 | + $sql .= " WHERE name like 'EXTERNAL_RSS_TITLE_%'"; |
|
99 | + $sql .= " AND entity = ".$conf->entity; |
|
100 | + $result = $this->db->query($sql); |
|
101 | 101 | if ($result) |
102 | 102 | { |
103 | 103 | while ($obj = $this->db->fetch_object($result)) |
104 | 104 | { |
105 | - if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i',$obj->name,$reg)) |
|
105 | + if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) |
|
106 | 106 | { |
107 | 107 | // Definie la boite si on a trouvee une ancienne configuration |
108 | 108 | //$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)"; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $sql = array(); |
117 | 117 | |
118 | - return $this->_init($sql,$options); |
|
118 | + return $this->_init($sql, $options); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @param string $options Options when enabling module ('', 'noboxes') |
127 | 127 | * @return int 1 if OK, 0 if KO |
128 | 128 | */ |
129 | - function remove($options='') |
|
129 | + function remove($options = '') |
|
130 | 130 | { |
131 | 131 | $sql = array(); |
132 | 132 | |
133 | 133 | // Delete old declarations of RSS box |
134 | 134 | $this->boxes[0]['file'] = "box_external_rss.php"; |
135 | 135 | |
136 | - return $this->_remove($sql,$options); |
|
136 | + return $this->_remove($sql, $options); |
|
137 | 137 | } |
138 | 138 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup socialnetworks |
24 | 24 | * \brief Description and activation file for module SocialNetworks |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class to describe a SocialNetworks module |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function __construct($db) |
40 | 40 | { |
41 | - global $langs,$conf; |
|
41 | + global $langs, $conf; |
|
42 | 42 | |
43 | 43 | $this->db = $db; |
44 | 44 | $this->numero = 3400; |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | // Module position in the family on 2 digits ('01', '10', '20', ...) |
50 | 50 | $this->module_position = '20'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; |
54 | 54 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
55 | 55 | $this->version = 'dolibarr'; |
56 | 56 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
57 | 57 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
58 | 58 | // Name of image file used for this module. |
59 | - $this->picto='generic'; |
|
59 | + $this->picto = 'generic'; |
|
60 | 60 | |
61 | 61 | // Data directories to create when module is enabled |
62 | 62 | $this->dirs = array(); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | $this->config_page_url = array("socialnetworks.php"); |
66 | 66 | |
67 | 67 | // Dependencies |
68 | - $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | - $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
68 | + $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
73 | 73 | $this->langfiles = array(); |
74 | 74 | |
75 | 75 | // Constants |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param array $param Associative array containing label content and optional parameters |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - function addSticker(&$pdf,$outputlangs,$param) |
|
45 | + function addSticker(&$pdf, $outputlangs, $param) |
|
46 | 46 | { |
47 | 47 | // use this method in future refactoring |
48 | 48 | } |
@@ -63,162 +63,162 @@ discard block |
||
63 | 63 | * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
66 | + function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') |
|
67 | 67 | { |
68 | 68 | // phpcs:enable |
69 | - global $db,$mysoc,$conf,$langs; |
|
70 | - global $forceimgscalewidth,$forceimgscaleheight; |
|
69 | + global $db, $mysoc, $conf, $langs; |
|
70 | + global $forceimgscalewidth, $forceimgscaleheight; |
|
71 | 71 | |
72 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | - $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
72 | + $imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | + $imgscaleheight = (empty($forceimgscalewidth) ? 0.5 : $forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
74 | 74 | |
75 | 75 | // We are in a new page, then we must add a page |
76 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
76 | + if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) { |
|
77 | 77 | $pdf->AddPage(); |
78 | 78 | } |
79 | - $this->_First=0; |
|
80 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
81 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
79 | + $this->_First = 0; |
|
80 | + $_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space)); |
|
81 | + $_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space)); |
|
82 | 82 | |
83 | 83 | // Define logo |
84 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | - if (! is_readable($logo)) |
|
84 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | + if (!is_readable($logo)) |
|
86 | 86 | { |
87 | - $logo=''; |
|
88 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | + $logo = ''; |
|
88 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
89 | 89 | { |
90 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
90 | + $logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
91 | 91 | } |
92 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
92 | + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | 93 | { |
94 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
94 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - $member=new Adherent($db); |
|
98 | + $member = new Adherent($db); |
|
99 | 99 | $member->id = $idmember; |
100 | 100 | $member->ref = $idmember; |
101 | 101 | |
102 | 102 | // Define photo |
103 | - $dir=$conf->adherent->dir_output; |
|
104 | - if (! empty($photo)) |
|
103 | + $dir = $conf->adherent->dir_output; |
|
104 | + if (!empty($photo)) |
|
105 | 105 | { |
106 | - $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
107 | - $photo=$dir.'/'.$file; |
|
108 | - if (! is_readable($photo)) $photo=''; |
|
106 | + $file = get_exdir(0, 0, 0, 0, $member, 'member').'photos/'.$photo; |
|
107 | + $photo = $dir.'/'.$file; |
|
108 | + if (!is_readable($photo)) $photo = ''; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Define background image |
112 | - $backgroundimage=''; |
|
113 | - if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
112 | + $backgroundimage = ''; |
|
113 | + if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
114 | 114 | { |
115 | - $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
115 | + $backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Print lines |
119 | 119 | if ($this->code == "CARD") |
120 | 120 | { |
121 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
121 | + $this->Tformat = $this->_Avery_Labels["CARD"]; |
|
122 | 122 | //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
123 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
123 | + $this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Background |
127 | 127 | if ($backgroundimage) |
128 | 128 | { |
129 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
129 | + $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); |
|
130 | 130 | } |
131 | 131 | |
132 | - $xleft=2; $ytop=2; |
|
132 | + $xleft = 2; $ytop = 2; |
|
133 | 133 | |
134 | 134 | // Top |
135 | - if ($header!='') |
|
135 | + if ($header != '') |
|
136 | 136 | { |
137 | 137 | if ($this->code == "CARD") |
138 | 138 | { |
139 | - $pdf->SetDrawColor(128,128,128); |
|
140 | - $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
141 | - $pdf->SetDrawColor(0,0,0); |
|
139 | + $pdf->SetDrawColor(128, 128, 128); |
|
140 | + $pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text |
|
141 | + $pdf->SetDrawColor(0, 0, 0); |
|
142 | 142 | } |
143 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
144 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
143 | + $pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text |
|
144 | + $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
148 | + $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); |
|
149 | 149 | |
150 | 150 | // Define widthtouse and heighttouse |
151 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
152 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
153 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
154 | - $tmp=dol_getImageSize($photo, false); |
|
151 | + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); |
|
152 | + $defaultratio = ($maxwidthtouse / $maxheighttouse); |
|
153 | + $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image |
|
154 | + $tmp = dol_getImageSize($photo, false); |
|
155 | 155 | if ($tmp['height']) |
156 | 156 | { |
157 | - $imgratio=$tmp['width']/$tmp['height']; |
|
157 | + $imgratio = $tmp['width'] / $tmp['height']; |
|
158 | 158 | if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
159 | 159 | else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
160 | 160 | } |
161 | 161 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
162 | 162 | |
163 | 163 | // Center |
164 | - if ($textright=='') // Only a left part |
|
164 | + if ($textright == '') // Only a left part |
|
165 | 165 | { |
166 | 166 | // Output left area |
167 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
167 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
168 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
169 | 169 | else |
170 | 170 | { |
171 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
172 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
171 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
172 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
173 | 173 | } |
174 | 174 | } |
175 | - else if ($textleft!='' && $textright!='') // |
|
175 | + else if ($textleft != '' && $textright != '') // |
|
176 | 176 | { |
177 | 177 | if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
178 | 178 | { |
179 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
180 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
181 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
182 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
179 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
180 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
181 | + $pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop); |
|
182 | + $pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
183 | 183 | } |
184 | 184 | else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
185 | 185 | { |
186 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
187 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
188 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
189 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
186 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
187 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
188 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
189 | + $pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
190 | 190 | } |
191 | 191 | else // text on halft left and text on half right |
192 | 192 | { |
193 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
195 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
196 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
193 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
194 | + $pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
195 | + $pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop); |
|
196 | + $pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | else // Only a right part |
200 | 200 | { |
201 | 201 | // Output right area |
202 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
203 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
202 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
203 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
204 | 204 | else |
205 | 205 | { |
206 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
207 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
206 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
207 | + $pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | // Bottom |
212 | - if ($footer!='') |
|
212 | + if ($footer != '') |
|
213 | 213 | { |
214 | 214 | if ($this->code == "CARD") |
215 | 215 | { |
216 | - $pdf->SetDrawColor(128,128,128); |
|
217 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
218 | - $pdf->SetDrawColor(0,0,0); |
|
216 | + $pdf->SetDrawColor(128, 128, 128); |
|
217 | + $pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2); |
|
218 | + $pdf->SetDrawColor(0, 0, 0); |
|
219 | 219 | } |
220 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
221 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
220 | + $pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1); |
|
221 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C'); |
|
222 | 222 | } |
223 | 223 | //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
224 | 224 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | if ($this->_COUNTY == $this->_Y_Number) { |
228 | 228 | // Si on est en bas de page, on remonte le 'curseur' de position |
229 | 229 | $this->_COUNTX++; |
230 | - $this->_COUNTY=0; |
|
230 | + $this->_COUNTY = 0; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($this->_COUNTX == $this->_X_Number) { |
234 | 234 | // Si on est en bout de page, alors on repart sur une nouvelle page |
235 | - $this->_COUNTX=0; |
|
236 | - $this->_COUNTY=0; |
|
235 | + $this->_COUNTX = 0; |
|
236 | + $this->_COUNTY = 0; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | * @param int $nooutput 1=Generate only file on disk and do not return it on response |
249 | 249 | * @return int 1=OK, 0=KO |
250 | 250 | */ |
251 | - function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
251 | + function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) |
|
252 | 252 | { |
253 | 253 | // phpcs:enable |
254 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
254 | + global $user, $conf, $langs, $mysoc, $_Avery_Labels; |
|
255 | 255 | |
256 | - $this->code=$srctemplatepath; |
|
256 | + $this->code = $srctemplatepath; |
|
257 | 257 | |
258 | 258 | if (is_object($object)) |
259 | 259 | { |
260 | - if ($object->country == '-') $object->country=''; |
|
260 | + if ($object->country == '-') $object->country = ''; |
|
261 | 261 | |
262 | 262 | // List of values to scan for a replacement |
263 | - $substitutionarray = array ( |
|
263 | + $substitutionarray = array( |
|
264 | 264 | '__ID__'=>$object->rowid, |
265 | 265 | '__LOGIN__'=>$object->login, |
266 | 266 | '__FIRSTNAME__'=>$object->firstname, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | '__COUNTRY__'=>$object->country, |
274 | 274 | '__COUNTRY_CODE__'=>$object->country_code, |
275 | 275 | '__EMAIL__'=>$object->email, |
276 | - '__BIRTH__'=>dol_print_date($object->birth,'day'), |
|
276 | + '__BIRTH__'=>dol_print_date($object->birth, 'day'), |
|
277 | 277 | '__TYPE__'=>$object->type, |
278 | 278 | '__YEAR__'=>$year, |
279 | 279 | '__MONTH__'=>$month, |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | complete_substitutions_array($substitutionarray, $langs); |
285 | 285 | |
286 | 286 | // For business cards |
287 | - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
287 | + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
291 | 291 | |
292 | 292 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
293 | + if ($nb <= 0) $nb = 1; // Protection to avoid empty page |
|
294 | 294 | |
295 | - for($j=0;$j<$nb;$j++) |
|
295 | + for ($j = 0; $j < $nb; $j++) |
|
296 | 296 | { |
297 | - $arrayofmembers[]=array( |
|
297 | + $arrayofmembers[] = array( |
|
298 | 298 | 'textleft'=>$textleft, |
299 | 299 | 'textheader'=>$textheader, |
300 | 300 | 'textfooter'=>$textfooter, |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | //var_dump($arrayofrecords);exit; |
315 | 315 | |
316 | 316 | $this->Tformat = $_Avery_Labels[$this->code]; |
317 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
317 | + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } |
|
318 | 318 | $this->type = 'pdf'; |
319 | 319 | // standard format or custom |
320 | - if ($this->Tformat['paper-size']!='custom') { |
|
320 | + if ($this->Tformat['paper-size'] != 'custom') { |
|
321 | 321 | $this->format = $this->Tformat['paper-size']; |
322 | 322 | } else { |
323 | 323 | //custom |
324 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
324 | + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
325 | 325 | $this->format = $resolution; |
326 | 326 | } |
327 | 327 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
328 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
329 | 329 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
330 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
330 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
331 | 331 | |
332 | 332 | // Load traductions files requiredby by page |
333 | 333 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
334 | 334 | |
335 | 335 | if (empty($mode) || $mode == 'member') |
336 | 336 | { |
337 | - $title=$outputlangs->transnoentities('MembersCards'); |
|
338 | - $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
337 | + $title = $outputlangs->transnoentities('MembersCards'); |
|
338 | + $keywords = $outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
339 | 339 | } |
340 | 340 | else |
341 | 341 | { |
342 | - dol_print_error('','Bad value for $mode'); |
|
342 | + dol_print_error('', 'Bad value for $mode'); |
|
343 | 343 | return -1; |
344 | 344 | } |
345 | 345 | |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | |
360 | 360 | //var_dump($file);exit; |
361 | 361 | |
362 | - if (! file_exists($dir)) |
|
362 | + if (!file_exists($dir)) |
|
363 | 363 | { |
364 | 364 | if (dol_mkdir($dir) < 0) |
365 | 365 | { |
366 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
366 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
371 | + $pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']); |
|
372 | 372 | |
373 | 373 | if (class_exists('TCPDF')) |
374 | 374 | { |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
383 | 383 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
384 | 384 | $pdf->SetKeyWords($keywords); |
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
385 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
386 | 386 | |
387 | - $pdf->SetMargins(0,0); |
|
387 | + $pdf->SetMargins(0, 0); |
|
388 | 388 | $pdf->SetAutoPageBreak(false); |
389 | 389 | |
390 | 390 | $this->_Metric_Doc = $this->Tformat['metric']; |
391 | 391 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
392 | - $posX=1; |
|
393 | - $posY=1; |
|
394 | - if ($posX > 0) $posX--; else $posX=0; |
|
395 | - if ($posY > 0) $posY--; else $posY=0; |
|
392 | + $posX = 1; |
|
393 | + $posY = 1; |
|
394 | + if ($posX > 0) $posX--; else $posX = 0; |
|
395 | + if ($posY > 0) $posY--; else $posY = 0; |
|
396 | 396 | $this->_COUNTX = $posX; |
397 | 397 | $this->_COUNTY = $posY; |
398 | 398 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -403,10 +403,10 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | // Add each record |
406 | - foreach($arrayofrecords as $val) |
|
406 | + foreach ($arrayofrecords as $val) |
|
407 | 407 | { |
408 | 408 | // imprime le texte specifique sur la carte |
409 | - $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']); |
|
409 | + $this->Add_PDF_card($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['id'], $val['photo']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | //$pdf->SetXY(10, 295); |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | |
415 | 415 | |
416 | 416 | // Output to file |
417 | - $pdf->Output($file,'F'); |
|
417 | + $pdf->Output($file, 'F'); |
|
418 | 418 | |
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
419 | + if (!empty($conf->global->MAIN_UMASK)) |
|
420 | 420 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
421 | 421 | |
422 | 422 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | { |
428 | 428 | clearstatcache(); |
429 | 429 | |
430 | - $attachment=true; |
|
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
432 | - $type=dol_mimetype($filename); |
|
430 | + $attachment = true; |
|
431 | + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; |
|
432 | + $type = dol_mimetype($filename); |
|
433 | 433 | |
434 | 434 | //if ($encoding) header('Content-Encoding: '.$encoding); |
435 | 435 | if ($type) header('Content-Type: '.$type); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | 50 | */ |
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
51 | + function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | // phpcs:enable |
54 | 54 | global $conf; |
55 | 55 | |
56 | - $type='member'; |
|
57 | - $liste=array(); |
|
56 | + $type = 'member'; |
|
57 | + $liste = array(); |
|
58 | 58 | |
59 | 59 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
60 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
60 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | 62 | return $liste; |
63 | 63 | } |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param string $template pdf generenate document class to use default 'standard' |
77 | 77 | * @return int <0 if KO, >0 if OK |
78 | 78 | */ |
79 | -function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard') |
|
79 | +function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard') |
|
80 | 80 | { |
81 | 81 | // phpcs:enable |
82 | - global $conf,$langs; |
|
82 | + global $conf, $langs; |
|
83 | 83 | $langs->load("members"); |
84 | 84 | |
85 | - $error=0; |
|
85 | + $error = 0; |
|
86 | 86 | |
87 | 87 | // Increase limit for PDF build |
88 | - $err=error_reporting(); |
|
88 | + $err = error_reporting(); |
|
89 | 89 | error_reporting(0); |
90 | 90 | @set_time_limit(120); |
91 | 91 | error_reporting($err); |
92 | 92 | |
93 | - $code=''; |
|
94 | - $srctemplatepath=''; |
|
93 | + $code = ''; |
|
94 | + $srctemplatepath = ''; |
|
95 | 95 | |
96 | 96 | // Positionne le modele sur le nom du modele a utiliser |
97 | - if (! dol_strlen($modele)) |
|
97 | + if (!dol_strlen($modele)) |
|
98 | 98 | { |
99 | - if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
99 | + if (!empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
100 | 100 | { |
101 | 101 | $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
102 | 102 | } |
@@ -105,33 +105,33 @@ discard block |
||
105 | 105 | $code = $modele; |
106 | 106 | } |
107 | 107 | } |
108 | - else $code=$modele; |
|
108 | + else $code = $modele; |
|
109 | 109 | |
110 | 110 | // If selected modele is a filename template (then $modele="modelname:filename") |
111 | - $tmp=explode(':',$template,2); |
|
112 | - if (! empty($tmp[1])) |
|
111 | + $tmp = explode(':', $template, 2); |
|
112 | + if (!empty($tmp[1])) |
|
113 | 113 | { |
114 | - $template=$tmp[0]; |
|
115 | - $srctemplatepath=$tmp[1]; |
|
114 | + $template = $tmp[0]; |
|
115 | + $srctemplatepath = $tmp[1]; |
|
116 | 116 | } |
117 | - else $srctemplatepath=$code; |
|
117 | + else $srctemplatepath = $code; |
|
118 | 118 | |
119 | 119 | // Search template files |
120 | - $file=''; $classname=''; $filefound=0; |
|
121 | - $dirmodels=array('/'); |
|
122 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | - foreach($dirmodels as $reldir) |
|
120 | + $file = ''; $classname = ''; $filefound = 0; |
|
121 | + $dirmodels = array('/'); |
|
122 | + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
123 | + foreach ($dirmodels as $reldir) |
|
124 | 124 | { |
125 | - foreach(array('doc','pdf') as $prefix) |
|
125 | + foreach (array('doc', 'pdf') as $prefix) |
|
126 | 126 | { |
127 | 127 | $file = $prefix."_".$template.".class.php"; |
128 | 128 | |
129 | 129 | // On verifie l'emplacement du modele |
130 | - $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0); |
|
130 | + $file = dol_buildpath($reldir."core/modules/member/doc/".$file, 0); |
|
131 | 131 | if (file_exists($file)) |
132 | 132 | { |
133 | - $filefound=1; |
|
134 | - $classname=$prefix.'_'.$template; |
|
133 | + $filefound = 1; |
|
134 | + $classname = $prefix.'_'.$template; |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | } |
@@ -148,23 +148,23 @@ discard block |
||
148 | 148 | |
149 | 149 | // We save charset_output to restore it because write_file can change it if needed for |
150 | 150 | // output format that does not support UTF8. |
151 | - $sav_charset_output=$outputlangs->charset_output; |
|
151 | + $sav_charset_output = $outputlangs->charset_output; |
|
152 | 152 | if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) |
153 | 153 | { |
154 | - $outputlangs->charset_output=$sav_charset_output; |
|
154 | + $outputlangs->charset_output = $sav_charset_output; |
|
155 | 155 | return 1; |
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $outputlangs->charset_output=$sav_charset_output; |
|
160 | - dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
|
159 | + $outputlangs->charset_output = $sav_charset_output; |
|
160 | + dol_print_error($db, "members_card_pdf_create Error: ".$obj->error); |
|
161 | 161 | return -1; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | else |
166 | 166 | { |
167 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
167 | + dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file)); |
|
168 | 168 | return -1; |
169 | 169 | } |
170 | 170 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * \brief Fichier de description et activation du module Ficheinter |
29 | 29 | */ |
30 | 30 | |
31 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
31 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->family = "crm"; |
53 | 53 | $this->module_position = '45'; |
54 | 54 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
55 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
56 | 56 | $this->description = "Gestion des fiches d'intervention"; |
57 | 57 | |
58 | 58 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $this->depends = array("modSociete"); |
69 | 69 | $this->requiredby = array(); |
70 | 70 | $this->conflictwith = array(); |
71 | - $this->langfiles = array("bills","companies","interventions"); |
|
71 | + $this->langfiles = array("bills", "companies", "interventions"); |
|
72 | 72 | |
73 | 73 | // Config pages |
74 | 74 | $this->config_page_url = array("fichinter.php"); |
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $this->const[$r][0] = "FICHEINTER_ADDON_PDF"; |
81 | 81 | $this->const[$r][1] = "chaine"; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | $r++; |
89 | 89 | |
90 | 90 | // Boxes |
91 | - $this->boxes = array(0=>array('file'=>'box_ficheinter.php','enabledbydefaulton'=>'Home')); |
|
91 | + $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home')); |
|
92 | 92 | |
93 | 93 | // Permissions |
94 | 94 | $this->rights = array(); |
95 | 95 | $this->rights_class = 'ficheinter'; |
96 | - $r=0; |
|
96 | + $r = 0; |
|
97 | 97 | |
98 | 98 | $r++; |
99 | 99 | $this->rights[$r][0] = 61; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel'; |
129 | 129 | $this->rights[$r][2] = 'r'; |
130 | 130 | $this->rights[$r][3] = 0; |
131 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
131 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
132 | 132 | $this->rights[$r][5] = 'send'; |
133 | 133 | |
134 | 134 | $r++; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->rights[$r][1] = 'Valider les fiches d\'intervention '; |
137 | 137 | $this->rights[$r][2] = 'a'; |
138 | 138 | $this->rights[$r][3] = 0; |
139 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
139 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
140 | 140 | $this->rights[$r][5] = 'validate'; |
141 | 141 | |
142 | 142 | $r++; |
@@ -144,28 +144,28 @@ discard block |
||
144 | 144 | $this->rights[$r][1] = 'Dévalider les fiches d\'intervention'; |
145 | 145 | $this->rights[$r][2] = 'a'; |
146 | 146 | $this->rights[$r][3] = 0; |
147 | - $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
147 | + $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on |
|
148 | 148 | $this->rights[$r][5] = 'unvalidate'; |
149 | 149 | |
150 | 150 | |
151 | 151 | // Menus |
152 | 152 | //------- |
153 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
153 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
154 | 154 | |
155 | 155 | |
156 | 156 | //Exports |
157 | 157 | //-------- |
158 | - $r=1; |
|
159 | - |
|
160 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
161 | - $this->export_label[$r]='InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
162 | - $this->export_permission[$r]=array(array("ficheinter","export")); |
|
163 | - $this->export_fields_array[$r]=array( |
|
164 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', |
|
165 | - 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', |
|
166 | - 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation", |
|
167 | - 'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId', |
|
168 | - 'fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc" |
|
158 | + $r = 1; |
|
159 | + |
|
160 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
161 | + $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
162 | + $this->export_permission[$r] = array(array("ficheinter", "export")); |
|
163 | + $this->export_fields_array[$r] = array( |
|
164 | + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', 's.phone'=>'Phone', |
|
165 | + 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', |
|
166 | + 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation", |
|
167 | + 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId', |
|
168 | + 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc" |
|
169 | 169 | ); |
170 | 170 | //$this->export_TypeFields_array[$r]=array( |
171 | 171 | // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', |
@@ -174,28 +174,28 @@ discard block |
||
174 | 174 | // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", |
175 | 175 | // 'fd.total_ht'=>"Numeric" |
176 | 176 | //); |
177 | - $this->export_TypeFields_array[$r]=array( |
|
178 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text', |
|
179 | - 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date", |
|
180 | - 'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', |
|
181 | - 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric" |
|
177 | + $this->export_TypeFields_array[$r] = array( |
|
178 | + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text', |
|
179 | + 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 'f.ref'=>"Text", 'f.datec'=>"Date", |
|
180 | + 'f.duree'=>"Duree", 'f.fk_statut'=>'Statut', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', |
|
181 | + 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric" |
|
182 | 182 | ); |
183 | - $this->export_entities_array[$r]=array( |
|
184 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', |
|
185 | - 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company', |
|
186 | - 's.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention", |
|
187 | - 'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line", |
|
188 | - 'fd.duree'=>'inter_line','fd.description'=>'inter_line' |
|
183 | + $this->export_entities_array[$r] = array( |
|
184 | + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', |
|
185 | + 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', |
|
186 | + 's.code_compta_fournisseur'=>'company', 'f.rowid'=>"intervention", 'f.ref'=>"intervention", 'f.datec'=>"intervention", 'f.duree'=>"intervention", |
|
187 | + 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line", |
|
188 | + 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line' |
|
189 | 189 | ); |
190 | - $this->export_dependencies_array[$r]=array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
191 | - |
|
192 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
193 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
194 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
195 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; |
|
196 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; |
|
197 | - $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; |
|
198 | - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention').')'; |
|
190 | + $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
191 | + |
|
192 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
193 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
194 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
|
195 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; |
|
196 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; |
|
197 | + $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; |
|
198 | + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')'; |
|
199 | 199 | $r++; |
200 | 200 | } |
201 | 201 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param string $options Options when enabling module ('', 'noboxes') |
209 | 209 | * @return int 1 if OK, 0 if KO |
210 | 210 | */ |
211 | - function init($options='') |
|
211 | + function init($options = '') |
|
212 | 212 | { |
213 | 213 | global $conf; |
214 | 214 | |
@@ -220,6 +220,6 @@ discard block |
||
220 | 220 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")", |
221 | 221 | ); |
222 | 222 | |
223 | - return $this->_init($sql,$options); |
|
223 | + return $this->_init($sql, $options); |
|
224 | 224 | } |
225 | 225 | } |