@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | public $db; |
34 | 34 | |
35 | 35 | /** |
36 | - * @var string Error code (or message) |
|
37 | - */ |
|
38 | - public $error=''; |
|
36 | + * @var string Error code (or message) |
|
37 | + */ |
|
38 | + public $error=''; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -50,99 +50,99 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
53 | - /** |
|
54 | - * Show a combo list with contracts qualified for a third party |
|
55 | - * |
|
56 | - * @param int $socid Id third party (-1=all, 0=only interventions not linked to a third party, id=intervention not linked or linked to third party id) |
|
57 | - * @param int $selected Id intervention preselected |
|
58 | - * @param string $htmlname Nom de la zone html |
|
59 | - * @param int $maxlength Maximum length of label |
|
60 | - * @param int $showempty Show empty line |
|
61 | - * @return int Nbre of project if OK, <0 if KO |
|
62 | - */ |
|
63 | - function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
64 | - { |
|
53 | + /** |
|
54 | + * Show a combo list with contracts qualified for a third party |
|
55 | + * |
|
56 | + * @param int $socid Id third party (-1=all, 0=only interventions not linked to a third party, id=intervention not linked or linked to third party id) |
|
57 | + * @param int $selected Id intervention preselected |
|
58 | + * @param string $htmlname Nom de la zone html |
|
59 | + * @param int $maxlength Maximum length of label |
|
60 | + * @param int $showempty Show empty line |
|
61 | + * @return int Nbre of project if OK, <0 if KO |
|
62 | + */ |
|
63 | + function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
64 | + { |
|
65 | 65 | // phpcs:enable |
66 | - global $db,$user,$conf,$langs; |
|
66 | + global $db,$user,$conf,$langs; |
|
67 | 67 | |
68 | - $out=''; |
|
68 | + $out=''; |
|
69 | 69 | |
70 | - $hideunselectables=false; |
|
70 | + $hideunselectables=false; |
|
71 | 71 | |
72 | - // Search all contacts |
|
73 | - $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
|
74 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
75 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
76 | - if ($socid != '') |
|
77 | - { |
|
78 | - if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | - else $sql.= " AND f.fk_soc = ".$socid; |
|
80 | - } |
|
72 | + // Search all contacts |
|
73 | + $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
|
74 | + $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
75 | + $sql.= " WHERE f.entity = ".$conf->entity; |
|
76 | + if ($socid != '') |
|
77 | + { |
|
78 | + if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | + else $sql.= " AND f.fk_soc = ".$socid; |
|
80 | + } |
|
81 | 81 | |
82 | - dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
|
83 | - $resql=$db->query($sql); |
|
84 | - if ($resql) |
|
85 | - { |
|
86 | - $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
88 | - $num = $db->num_rows($resql); |
|
89 | - $i = 0; |
|
90 | - if ($num) |
|
91 | - { |
|
92 | - while ($i < $num) |
|
93 | - { |
|
94 | - $obj = $db->fetch_object($resql); |
|
95 | - // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
|
96 | - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
97 | - { |
|
98 | - // Do nothing |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - $labeltoshow=dol_trunc($obj->ref,18); |
|
103 | - if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
|
104 | - { |
|
105 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
106 | - } |
|
107 | - else |
|
108 | - { |
|
109 | - $disabled=0; |
|
110 | - if (! $obj->fk_statut > 0) |
|
111 | - { |
|
112 | - $disabled=1; |
|
113 | - $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
114 | - } |
|
115 | - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
116 | - { |
|
117 | - $disabled=1; |
|
118 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
119 | - } |
|
82 | + dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
|
83 | + $resql=$db->query($sql); |
|
84 | + if ($resql) |
|
85 | + { |
|
86 | + $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | + if ($showempty) $out.='<option value="0"> </option>'; |
|
88 | + $num = $db->num_rows($resql); |
|
89 | + $i = 0; |
|
90 | + if ($num) |
|
91 | + { |
|
92 | + while ($i < $num) |
|
93 | + { |
|
94 | + $obj = $db->fetch_object($resql); |
|
95 | + // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
|
96 | + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
97 | + { |
|
98 | + // Do nothing |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + $labeltoshow=dol_trunc($obj->ref,18); |
|
103 | + if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
|
104 | + { |
|
105 | + $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
106 | + } |
|
107 | + else |
|
108 | + { |
|
109 | + $disabled=0; |
|
110 | + if (! $obj->fk_statut > 0) |
|
111 | + { |
|
112 | + $disabled=1; |
|
113 | + $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
114 | + } |
|
115 | + if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
116 | + { |
|
117 | + $disabled=1; |
|
118 | + $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
119 | + } |
|
120 | 120 | |
121 | - if ($hideunselectables && $disabled) |
|
122 | - { |
|
123 | - $resultat=''; |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
128 | - if ($disabled) $resultat.=' disabled'; |
|
129 | - $resultat.='>'.$labeltoshow; |
|
130 | - $resultat.='</option>'; |
|
131 | - } |
|
132 | - $out.=$resultat; |
|
133 | - } |
|
134 | - } |
|
135 | - $i++; |
|
136 | - } |
|
137 | - } |
|
138 | - $out.='</select>'; |
|
139 | - $db->free($resql); |
|
140 | - return $out; |
|
141 | - } |
|
142 | - else |
|
143 | - { |
|
144 | - dol_print_error($db); |
|
145 | - return ''; |
|
146 | - } |
|
147 | - } |
|
121 | + if ($hideunselectables && $disabled) |
|
122 | + { |
|
123 | + $resultat=''; |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + $resultat='<option value="'.$obj->rowid.'"'; |
|
128 | + if ($disabled) $resultat.=' disabled'; |
|
129 | + $resultat.='>'.$labeltoshow; |
|
130 | + $resultat.='</option>'; |
|
131 | + } |
|
132 | + $out.=$resultat; |
|
133 | + } |
|
134 | + } |
|
135 | + $i++; |
|
136 | + } |
|
137 | + } |
|
138 | + $out.='</select>'; |
|
139 | + $db->free($resql); |
|
140 | + return $out; |
|
141 | + } |
|
142 | + else |
|
143 | + { |
|
144 | + dol_print_error($db); |
|
145 | + return ''; |
|
146 | + } |
|
147 | + } |
|
148 | 148 | } |
@@ -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 | /** |
@@ -60,31 +60,31 @@ discard block |
||
60 | 60 | * @param int $showempty Show empty line |
61 | 61 | * @return int Nbre of project if OK, <0 if KO |
62 | 62 | */ |
63 | - function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
63 | + function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) |
|
64 | 64 | { |
65 | 65 | // phpcs:enable |
66 | - global $db,$user,$conf,$langs; |
|
66 | + global $db, $user, $conf, $langs; |
|
67 | 67 | |
68 | - $out=''; |
|
68 | + $out = ''; |
|
69 | 69 | |
70 | - $hideunselectables=false; |
|
70 | + $hideunselectables = false; |
|
71 | 71 | |
72 | 72 | // Search all contacts |
73 | 73 | $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
74 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
75 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
74 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
75 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
76 | 76 | if ($socid != '') |
77 | 77 | { |
78 | - if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | - else $sql.= " AND f.fk_soc = ".$socid; |
|
78 | + if ($socid == '0') $sql .= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | + else $sql .= " AND f.fk_soc = ".$socid; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
83 | - $resql=$db->query($sql); |
|
83 | + $resql = $db->query($sql); |
|
84 | 84 | if ($resql) |
85 | 85 | { |
86 | - $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
86 | + $out .= '<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | + if ($showempty) $out .= '<option value="0"> </option>'; |
|
88 | 88 | $num = $db->num_rows($resql); |
89 | 89 | $i = 0; |
90 | 90 | if ($num) |
@@ -93,49 +93,49 @@ discard block |
||
93 | 93 | { |
94 | 94 | $obj = $db->fetch_object($resql); |
95 | 95 | // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
96 | - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
96 | + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) |
|
97 | 97 | { |
98 | 98 | // Do nothing |
99 | 99 | } |
100 | 100 | else |
101 | 101 | { |
102 | - $labeltoshow=dol_trunc($obj->ref,18); |
|
102 | + $labeltoshow = dol_trunc($obj->ref, 18); |
|
103 | 103 | if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
104 | 104 | { |
105 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
105 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
106 | 106 | } |
107 | 107 | else |
108 | 108 | { |
109 | - $disabled=0; |
|
110 | - if (! $obj->fk_statut > 0) |
|
109 | + $disabled = 0; |
|
110 | + if (!$obj->fk_statut > 0) |
|
111 | 111 | { |
112 | - $disabled=1; |
|
113 | - $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
112 | + $disabled = 1; |
|
113 | + $labeltoshow .= ' ('.$langs->trans("Draft").')'; |
|
114 | 114 | } |
115 | - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
115 | + if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
116 | 116 | { |
117 | - $disabled=1; |
|
118 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
117 | + $disabled = 1; |
|
118 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if ($hideunselectables && $disabled) |
122 | 122 | { |
123 | - $resultat=''; |
|
123 | + $resultat = ''; |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
128 | - if ($disabled) $resultat.=' disabled'; |
|
129 | - $resultat.='>'.$labeltoshow; |
|
130 | - $resultat.='</option>'; |
|
127 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
128 | + if ($disabled) $resultat .= ' disabled'; |
|
129 | + $resultat .= '>'.$labeltoshow; |
|
130 | + $resultat .= '</option>'; |
|
131 | 131 | } |
132 | - $out.=$resultat; |
|
132 | + $out .= $resultat; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | $i++; |
136 | 136 | } |
137 | 137 | } |
138 | - $out.='</select>'; |
|
138 | + $out .= '</select>'; |
|
139 | 139 | $db->free($resql); |
140 | 140 | return $out; |
141 | 141 | } |
@@ -75,8 +75,11 @@ discard block |
||
75 | 75 | $sql.= " WHERE f.entity = ".$conf->entity; |
76 | 76 | if ($socid != '') |
77 | 77 | { |
78 | - if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | - else $sql.= " AND f.fk_soc = ".$socid; |
|
78 | + if ($socid == '0') { |
|
79 | + $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
80 | + } else { |
|
81 | + $sql.= " AND f.fk_soc = ".$socid; |
|
82 | + } |
|
80 | 83 | } |
81 | 84 | |
82 | 85 | dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
@@ -84,7 +87,9 @@ discard block |
||
84 | 87 | if ($resql) |
85 | 88 | { |
86 | 89 | $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
87 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
90 | + if ($showempty) { |
|
91 | + $out.='<option value="0"> </option>'; |
|
92 | + } |
|
88 | 93 | $num = $db->num_rows($resql); |
89 | 94 | $i = 0; |
90 | 95 | if ($num) |
@@ -96,15 +101,13 @@ discard block |
||
96 | 101 | if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
97 | 102 | { |
98 | 103 | // Do nothing |
99 | - } |
|
100 | - else |
|
104 | + } else |
|
101 | 105 | { |
102 | 106 | $labeltoshow=dol_trunc($obj->ref,18); |
103 | 107 | if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
104 | 108 | { |
105 | 109 | $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
106 | - } |
|
107 | - else |
|
110 | + } else |
|
108 | 111 | { |
109 | 112 | $disabled=0; |
110 | 113 | if (! $obj->fk_statut > 0) |
@@ -121,11 +124,12 @@ discard block |
||
121 | 124 | if ($hideunselectables && $disabled) |
122 | 125 | { |
123 | 126 | $resultat=''; |
124 | - } |
|
125 | - else |
|
127 | + } else |
|
126 | 128 | { |
127 | 129 | $resultat='<option value="'.$obj->rowid.'"'; |
128 | - if ($disabled) $resultat.=' disabled'; |
|
130 | + if ($disabled) { |
|
131 | + $resultat.=' disabled'; |
|
132 | + } |
|
129 | 133 | $resultat.='>'.$labeltoshow; |
130 | 134 | $resultat.='</option>'; |
131 | 135 | } |
@@ -138,8 +142,7 @@ discard block |
||
138 | 142 | $out.='</select>'; |
139 | 143 | $db->free($resql); |
140 | 144 | return $out; |
141 | - } |
|
142 | - else |
|
145 | + } else |
|
143 | 146 | { |
144 | 147 | dol_print_error($db); |
145 | 148 | return ''; |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public $db; |
38 | 38 | |
39 | - var $dir; // Directory with all core and external triggers files |
|
39 | + var $dir; // Directory with all core and external triggers files |
|
40 | 40 | |
41 | 41 | /** |
42 | - * @var string[] Error codes (or messages) |
|
43 | - */ |
|
44 | - public $errors = array(); |
|
42 | + * @var string[] Error codes (or messages) |
|
43 | + */ |
|
44 | + public $errors = array(); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Constructor |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | // Check parameters |
72 | 72 | if (! is_object($object) || ! is_object($conf)) // Error |
73 | 73 | { |
74 | - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
74 | + $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
75 | 75 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
76 | - $this->errors[]=$this->error; |
|
76 | + $this->errors[]=$this->error; |
|
77 | 77 | return -1; |
78 | 78 | } |
79 | 79 | if (! is_object($langs)) // Warning |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | $files = array(); |
93 | 93 | $modules = array(); |
94 | 94 | $orders = array(); |
95 | - $i=0; |
|
95 | + $i=0; |
|
96 | 96 | |
97 | - $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
97 | + $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
98 | 98 | foreach($dirtriggers as $reldir) |
99 | 99 | { |
100 | 100 | $dir=dol_buildpath($reldir,0); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | { |
112 | 112 | if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) |
113 | 113 | { |
114 | - $part1=$reg[1]; |
|
115 | - $part2=$reg[2]; |
|
116 | - $part3=$reg[3]; |
|
114 | + $part1=$reg[1]; |
|
115 | + $part2=$reg[2]; |
|
116 | + $part3=$reg[3]; |
|
117 | 117 | |
118 | 118 | $nbfile++; |
119 | 119 | |
@@ -175,22 +175,22 @@ discard block |
||
175 | 175 | $objMod = new $modName($this->db); |
176 | 176 | if ($objMod) |
177 | 177 | { |
178 | - $result=0; |
|
179 | - |
|
180 | - if (method_exists($objMod, 'runTrigger')) // New method to implement |
|
181 | - { |
|
182 | - //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
|
183 | - $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
184 | - } |
|
185 | - elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
|
186 | - { |
|
187 | - dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
|
188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
189 | - } |
|
190 | - else |
|
191 | - { |
|
192 | - dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); |
|
193 | - } |
|
178 | + $result=0; |
|
179 | + |
|
180 | + if (method_exists($objMod, 'runTrigger')) // New method to implement |
|
181 | + { |
|
182 | + //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
|
183 | + $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
184 | + } |
|
185 | + elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
|
186 | + { |
|
187 | + dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
|
188 | + $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
189 | + } |
|
190 | + else |
|
191 | + { |
|
192 | + dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | if ($result > 0) |
196 | 196 | { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | else |
218 | - { |
|
218 | + { |
|
219 | 219 | dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR); |
220 | 220 | } |
221 | 221 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); |
255 | 255 | if (is_array($forcedirtriggers)) |
256 | 256 | { |
257 | - $dirtriggers=$forcedirtriggers; |
|
257 | + $dirtriggers=$forcedirtriggers; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | foreach($dirtriggers as $reldir) |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | { |
275 | 275 | if (preg_match('/\.back$/',$file)) continue; |
276 | 276 | |
277 | - $part1=$reg[1]; |
|
278 | - $part2=$reg[2]; |
|
279 | - $part3=$reg[3]; |
|
277 | + $part1=$reg[1]; |
|
278 | + $part2=$reg[2]; |
|
279 | + $part3=$reg[3]; |
|
280 | 280 | |
281 | 281 | $modName = 'Interface'.ucfirst($reg[3]); |
282 | 282 | //print "file=$file"; print "modName=$modName"; exit; |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | |
318 | 318 | if (! class_exists($modName)) |
319 | 319 | { |
320 | - print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
|
321 | - continue; |
|
320 | + print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
|
321 | + continue; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | $objMod = new $modName($db); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $triggers[$j]['module']=strtolower($module); |
341 | 341 | } |
342 | 342 | |
343 | - // We set info of modules |
|
343 | + // We set info of modules |
|
344 | 344 | $triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); |
345 | 345 | $triggers[$j]['file'] = $files[$key]; |
346 | 346 | $triggers[$j]['fullpath'] = $fullpath[$key]; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public $db; |
38 | 38 | |
39 | - var $dir; // Directory with all core and external triggers files |
|
39 | + var $dir; // Directory with all core and external triggers files |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string[] Error codes (or messages) |
@@ -65,22 +65,22 @@ discard block |
||
65 | 65 | * @param Conf $conf Objet conf |
66 | 66 | * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. |
67 | 67 | */ |
68 | - function run_triggers($action,$object,$user,$langs,$conf) |
|
68 | + function run_triggers($action, $object, $user, $langs, $conf) |
|
69 | 69 | { |
70 | 70 | // phpcs:enable |
71 | 71 | // Check parameters |
72 | - if (! is_object($object) || ! is_object($conf)) // Error |
|
72 | + if (!is_object($object) || !is_object($conf)) // Error |
|
73 | 73 | { |
74 | - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
74 | + $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
75 | 75 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
76 | - $this->errors[]=$this->error; |
|
76 | + $this->errors[] = $this->error; |
|
77 | 77 | return -1; |
78 | 78 | } |
79 | - if (! is_object($langs)) // Warning |
|
79 | + if (!is_object($langs)) // Warning |
|
80 | 80 | { |
81 | 81 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
82 | 82 | } |
83 | - if (! is_object($user)) // Warning |
|
83 | + if (!is_object($user)) // Warning |
|
84 | 84 | { |
85 | 85 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
86 | 86 | global $db; |
@@ -92,43 +92,43 @@ discard block |
||
92 | 92 | $files = array(); |
93 | 93 | $modules = array(); |
94 | 94 | $orders = array(); |
95 | - $i=0; |
|
95 | + $i = 0; |
|
96 | 96 | |
97 | - $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
98 | - foreach($dirtriggers as $reldir) |
|
97 | + $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); |
|
98 | + foreach ($dirtriggers as $reldir) |
|
99 | 99 | { |
100 | - $dir=dol_buildpath($reldir,0); |
|
101 | - $newdir=dol_osencode($dir); |
|
100 | + $dir = dol_buildpath($reldir, 0); |
|
101 | + $newdir = dol_osencode($dir); |
|
102 | 102 | //print "xx".$dir;exit; |
103 | 103 | |
104 | 104 | // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) |
105 | - if (! is_dir($newdir)) continue; |
|
105 | + if (!is_dir($newdir)) continue; |
|
106 | 106 | |
107 | - $handle=opendir($newdir); |
|
107 | + $handle = opendir($newdir); |
|
108 | 108 | if (is_resource($handle)) |
109 | 109 | { |
110 | - while (($file = readdir($handle))!==false) |
|
110 | + while (($file = readdir($handle)) !== false) |
|
111 | 111 | { |
112 | - if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) |
|
112 | + if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) |
|
113 | 113 | { |
114 | - $part1=$reg[1]; |
|
115 | - $part2=$reg[2]; |
|
116 | - $part3=$reg[3]; |
|
114 | + $part1 = $reg[1]; |
|
115 | + $part2 = $reg[2]; |
|
116 | + $part3 = $reg[3]; |
|
117 | 117 | |
118 | 118 | $nbfile++; |
119 | 119 | |
120 | 120 | // Check if trigger file is disabled by name |
121 | - if (preg_match('/NORUN$/i',$file)) continue; |
|
121 | + if (preg_match('/NORUN$/i', $file)) continue; |
|
122 | 122 | // Check if trigger file is for a particular module |
123 | - $qualified=true; |
|
123 | + $qualified = true; |
|
124 | 124 | if (strtolower($reg[2]) != 'all') |
125 | 125 | { |
126 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
127 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
128 | - if (empty($conf->global->$constparam)) $qualified=false; |
|
126 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
127 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
128 | + if (empty($conf->global->$constparam)) $qualified = false; |
|
129 | 129 | } |
130 | 130 | |
131 | - if (! $qualified) |
|
131 | + if (!$qualified) |
|
132 | 132 | { |
133 | 133 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled", LOG_DEBUG); |
134 | 134 | continue; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $modName = "Interface".ucfirst($reg[3]); |
138 | 138 | //print "file=$file - modName=$modName\n"; |
139 | - if (in_array($modName,$modules)) // $modules = list of modName already loaded |
|
139 | + if (in_array($modName, $modules)) // $modules = list of modName already loaded |
|
140 | 140 | { |
141 | 141 | $langs->load("errors"); |
142 | 142 | dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | include_once $newdir.'/'.$file; |
149 | 149 | //print 'Done for '.$modName."\n"; |
150 | 150 | } |
151 | - catch(Exception $e) |
|
151 | + catch (Exception $e) |
|
152 | 152 | { |
153 | 153 | dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); |
154 | 154 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $modules[$i] = $modName; |
157 | 157 | $files[$i] = $file; |
158 | 158 | $fullpathfiles[$modName] = $newdir.'/'.$file; |
159 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
159 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
160 | 160 | |
161 | 161 | $i++; |
162 | 162 | } |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | $objMod = new $modName($this->db); |
176 | 176 | if ($objMod) |
177 | 177 | { |
178 | - $result=0; |
|
178 | + $result = 0; |
|
179 | 179 | |
180 | 180 | if (method_exists($objMod, 'runTrigger')) // New method to implement |
181 | 181 | { |
182 | 182 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
183 | - $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
183 | + $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); |
|
184 | 184 | } |
185 | 185 | elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
186 | 186 | { |
187 | 187 | dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
188 | + $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); |
|
189 | 189 | } |
190 | 190 | else |
191 | 191 | { |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); |
210 | 210 | $nbtotal++; |
211 | 211 | $nbko++; |
212 | - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors); |
|
213 | - else if (! empty($objMod->error)) $this->errors[]=$objMod->error; |
|
212 | + if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); |
|
213 | + else if (!empty($objMod->error)) $this->errors[] = $objMod->error; |
|
214 | 214 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); |
215 | 215 | } |
216 | 216 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. |
240 | 240 | * @return array Array list of triggers |
241 | 241 | */ |
242 | - function getTriggersList($forcedirtriggers=null) |
|
242 | + function getTriggersList($forcedirtriggers = null) |
|
243 | 243 | { |
244 | 244 | global $conf, $langs, $db; |
245 | 245 | |
@@ -251,39 +251,39 @@ discard block |
||
251 | 251 | $orders = array(); |
252 | 252 | $i = 0; |
253 | 253 | |
254 | - $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); |
|
254 | + $dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); |
|
255 | 255 | if (is_array($forcedirtriggers)) |
256 | 256 | { |
257 | - $dirtriggers=$forcedirtriggers; |
|
257 | + $dirtriggers = $forcedirtriggers; |
|
258 | 258 | } |
259 | 259 | |
260 | - foreach($dirtriggers as $reldir) |
|
260 | + foreach ($dirtriggers as $reldir) |
|
261 | 261 | { |
262 | - $dir=dol_buildpath($reldir,0); |
|
263 | - $newdir=dol_osencode($dir); |
|
262 | + $dir = dol_buildpath($reldir, 0); |
|
263 | + $newdir = dol_osencode($dir); |
|
264 | 264 | |
265 | 265 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) |
266 | - if (! is_dir($newdir)) continue; |
|
266 | + if (!is_dir($newdir)) continue; |
|
267 | 267 | |
268 | - $handle=opendir($newdir); |
|
268 | + $handle = opendir($newdir); |
|
269 | 269 | if (is_resource($handle)) |
270 | 270 | { |
271 | - while (($file = readdir($handle))!==false) |
|
271 | + while (($file = readdir($handle)) !== false) |
|
272 | 272 | { |
273 | - if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg)) |
|
273 | + if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) |
|
274 | 274 | { |
275 | - if (preg_match('/\.back$/',$file)) continue; |
|
275 | + if (preg_match('/\.back$/', $file)) continue; |
|
276 | 276 | |
277 | - $part1=$reg[1]; |
|
278 | - $part2=$reg[2]; |
|
279 | - $part3=$reg[3]; |
|
277 | + $part1 = $reg[1]; |
|
278 | + $part2 = $reg[2]; |
|
279 | + $part3 = $reg[3]; |
|
280 | 280 | |
281 | 281 | $modName = 'Interface'.ucfirst($reg[3]); |
282 | 282 | //print "file=$file"; print "modName=$modName"; exit; |
283 | - if (in_array($modName,$modules)) |
|
283 | + if (in_array($modName, $modules)) |
|
284 | 284 | { |
285 | 285 | $langs->load("errors"); |
286 | - print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>'; |
|
286 | + print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/").'</div>'; |
|
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | |
293 | 293 | $files[$i] = $file; |
294 | 294 | $fullpath[$i] = $dir.'/'.$file; |
295 | - $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file; |
|
296 | - $iscoreorexternal[$i] = ($reldir == '/core/triggers/'?'internal':'external'); |
|
295 | + $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file; |
|
296 | + $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external'); |
|
297 | 297 | $modules[$i] = $modName; |
298 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
298 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
299 | 299 | |
300 | 300 | $i++; |
301 | 301 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $modName = $modules[$key]; |
316 | 316 | if (empty($modName)) continue; |
317 | 317 | |
318 | - if (! class_exists($modName)) |
|
318 | + if (!class_exists($modName)) |
|
319 | 319 | { |
320 | 320 | print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
321 | 321 | continue; |
@@ -324,45 +324,45 @@ discard block |
||
324 | 324 | $objMod = new $modName($db); |
325 | 325 | |
326 | 326 | // Define disabledbyname and disabledbymodule |
327 | - $disabledbyname=0; |
|
328 | - $disabledbymodule=1; |
|
329 | - $module=''; |
|
327 | + $disabledbyname = 0; |
|
328 | + $disabledbymodule = 1; |
|
329 | + $module = ''; |
|
330 | 330 | |
331 | 331 | // Check if trigger file is disabled by name |
332 | - if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; |
|
332 | + if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1; |
|
333 | 333 | // Check if trigger file is for a particular module |
334 | - if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg)) |
|
334 | + if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) |
|
335 | 335 | { |
336 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
337 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
338 | - if (strtolower($module) == 'all') $disabledbymodule=0; |
|
339 | - else if (empty($conf->global->$constparam)) $disabledbymodule=2; |
|
340 | - $triggers[$j]['module']=strtolower($module); |
|
336 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
337 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
338 | + if (strtolower($module) == 'all') $disabledbymodule = 0; |
|
339 | + else if (empty($conf->global->$constparam)) $disabledbymodule = 2; |
|
340 | + $triggers[$j]['module'] = strtolower($module); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | // We set info of modules |
344 | - $triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); |
|
344 | + $triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto) : img_object('', 'generic'); |
|
345 | 345 | $triggers[$j]['file'] = $files[$key]; |
346 | 346 | $triggers[$j]['fullpath'] = $fullpath[$key]; |
347 | 347 | $triggers[$j]['relpath'] = $relpath[$key]; |
348 | 348 | $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; |
349 | 349 | $triggers[$j]['version'] = $objMod->getVersion(); |
350 | - $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick'); |
|
350 | + $triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick'); |
|
351 | 351 | if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; |
352 | 352 | |
353 | - $text ='<b>'.$langs->trans("Description").':</b><br>'; |
|
354 | - $text.=$objMod->getDesc().'<br>'; |
|
355 | - $text.='<br><b>'.$langs->trans("Status").':</b><br>'; |
|
353 | + $text = '<b>'.$langs->trans("Description").':</b><br>'; |
|
354 | + $text .= $objMod->getDesc().'<br>'; |
|
355 | + $text .= '<br><b>'.$langs->trans("Status").':</b><br>'; |
|
356 | 356 | if ($disabledbyname == 1) |
357 | 357 | { |
358 | - $text.=$langs->trans("TriggerDisabledByName").'<br>'; |
|
359 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
358 | + $text .= $langs->trans("TriggerDisabledByName").'<br>'; |
|
359 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
360 | 360 | } |
361 | 361 | else |
362 | 362 | { |
363 | - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>'; |
|
364 | - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>'; |
|
365 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
363 | + if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>'; |
|
364 | + if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>'; |
|
365 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $triggers[$j]['info'] = $text; |
@@ -69,20 +69,26 @@ discard block |
||
69 | 69 | { |
70 | 70 | // phpcs:enable |
71 | 71 | // Check parameters |
72 | - if (! is_object($object) || ! is_object($conf)) // Error |
|
72 | + if (! is_object($object) || ! is_object($conf)) { |
|
73 | + // Error |
|
73 | 74 | { |
74 | 75 | $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
76 | + } |
|
75 | 77 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
76 | 78 | $this->errors[]=$this->error; |
77 | 79 | return -1; |
78 | 80 | } |
79 | - if (! is_object($langs)) // Warning |
|
81 | + if (! is_object($langs)) { |
|
82 | + // Warning |
|
80 | 83 | { |
81 | 84 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
82 | 85 | } |
83 | - if (! is_object($user)) // Warning |
|
86 | + } |
|
87 | + if (! is_object($user)) { |
|
88 | + // Warning |
|
84 | 89 | { |
85 | 90 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
91 | + } |
|
86 | 92 | global $db; |
87 | 93 | $user = new User($db); |
88 | 94 | } |
@@ -102,7 +108,9 @@ discard block |
||
102 | 108 | //print "xx".$dir;exit; |
103 | 109 | |
104 | 110 | // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) |
105 | - if (! is_dir($newdir)) continue; |
|
111 | + if (! is_dir($newdir)) { |
|
112 | + continue; |
|
113 | + } |
|
106 | 114 | |
107 | 115 | $handle=opendir($newdir); |
108 | 116 | if (is_resource($handle)) |
@@ -118,14 +126,18 @@ discard block |
||
118 | 126 | $nbfile++; |
119 | 127 | |
120 | 128 | // Check if trigger file is disabled by name |
121 | - if (preg_match('/NORUN$/i',$file)) continue; |
|
129 | + if (preg_match('/NORUN$/i',$file)) { |
|
130 | + continue; |
|
131 | + } |
|
122 | 132 | // Check if trigger file is for a particular module |
123 | 133 | $qualified=true; |
124 | 134 | if (strtolower($reg[2]) != 'all') |
125 | 135 | { |
126 | 136 | $module=preg_replace('/^mod/i','',$reg[2]); |
127 | 137 | $constparam='MAIN_MODULE_'.strtoupper($module); |
128 | - if (empty($conf->global->$constparam)) $qualified=false; |
|
138 | + if (empty($conf->global->$constparam)) { |
|
139 | + $qualified=false; |
|
140 | + } |
|
129 | 141 | } |
130 | 142 | |
131 | 143 | if (! $qualified) |
@@ -136,9 +148,11 @@ discard block |
||
136 | 148 | |
137 | 149 | $modName = "Interface".ucfirst($reg[3]); |
138 | 150 | //print "file=$file - modName=$modName\n"; |
139 | - if (in_array($modName,$modules)) // $modules = list of modName already loaded |
|
151 | + if (in_array($modName,$modules)) { |
|
152 | + // $modules = list of modName already loaded |
|
140 | 153 | { |
141 | 154 | $langs->load("errors"); |
155 | + } |
|
142 | 156 | dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING); |
143 | 157 | continue; |
144 | 158 | } |
@@ -147,8 +161,7 @@ discard block |
||
147 | 161 | //print 'Todo for '.$modName." : ".$newdir.'/'.$file."\n"; |
148 | 162 | include_once $newdir.'/'.$file; |
149 | 163 | //print 'Done for '.$modName."\n"; |
150 | - } |
|
151 | - catch(Exception $e) |
|
164 | + } catch(Exception $e) |
|
152 | 165 | { |
153 | 166 | dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); |
154 | 167 | } |
@@ -170,24 +183,28 @@ discard block |
||
170 | 183 | foreach ($orders as $key => $value) |
171 | 184 | { |
172 | 185 | $modName = $modules[$key]; |
173 | - if (empty($modName)) continue; |
|
186 | + if (empty($modName)) { |
|
187 | + continue; |
|
188 | + } |
|
174 | 189 | |
175 | 190 | $objMod = new $modName($this->db); |
176 | 191 | if ($objMod) |
177 | 192 | { |
178 | 193 | $result=0; |
179 | 194 | |
180 | - if (method_exists($objMod, 'runTrigger')) // New method to implement |
|
195 | + if (method_exists($objMod, 'runTrigger')) { |
|
196 | + // New method to implement |
|
181 | 197 | { |
182 | 198 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
183 | 199 | $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
184 | 200 | } |
185 | - elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
|
201 | + } elseif (method_exists($objMod, 'run_trigger')) { |
|
202 | + // Deprecated method |
|
186 | 203 | { |
187 | 204 | dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
189 | 205 | } |
190 | - else |
|
206 | + $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
207 | + } else |
|
191 | 208 | { |
192 | 209 | dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); |
193 | 210 | } |
@@ -209,12 +226,14 @@ discard block |
||
209 | 226 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); |
210 | 227 | $nbtotal++; |
211 | 228 | $nbko++; |
212 | - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors); |
|
213 | - else if (! empty($objMod->error)) $this->errors[]=$objMod->error; |
|
229 | + if (! empty($objMod->errors)) { |
|
230 | + $this->errors=array_merge($this->errors,$objMod->errors); |
|
231 | + } else if (! empty($objMod->error)) { |
|
232 | + $this->errors[]=$objMod->error; |
|
233 | + } |
|
214 | 234 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); |
215 | 235 | } |
216 | - } |
|
217 | - else |
|
236 | + } else |
|
218 | 237 | { |
219 | 238 | dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR); |
220 | 239 | } |
@@ -224,8 +243,7 @@ discard block |
||
224 | 243 | { |
225 | 244 | dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko." - Nb of error string returned in this->errors = ".count($this->errors), LOG_ERR); |
226 | 245 | return -$nbko; |
227 | - } |
|
228 | - else |
|
246 | + } else |
|
229 | 247 | { |
230 | 248 | //dol_syslog(get_class($this)."::run_triggers Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_DEBUG); |
231 | 249 | return $nbok; |
@@ -263,7 +281,9 @@ discard block |
||
263 | 281 | $newdir=dol_osencode($dir); |
264 | 282 | |
265 | 283 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) |
266 | - if (! is_dir($newdir)) continue; |
|
284 | + if (! is_dir($newdir)) { |
|
285 | + continue; |
|
286 | + } |
|
267 | 287 | |
268 | 288 | $handle=opendir($newdir); |
269 | 289 | if (is_resource($handle)) |
@@ -272,7 +292,9 @@ discard block |
||
272 | 292 | { |
273 | 293 | if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg)) |
274 | 294 | { |
275 | - if (preg_match('/\.back$/',$file)) continue; |
|
295 | + if (preg_match('/\.back$/',$file)) { |
|
296 | + continue; |
|
297 | + } |
|
276 | 298 | |
277 | 299 | $part1=$reg[1]; |
278 | 300 | $part2=$reg[2]; |
@@ -284,8 +306,7 @@ discard block |
||
284 | 306 | { |
285 | 307 | $langs->load("errors"); |
286 | 308 | print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>'; |
287 | - } |
|
288 | - else |
|
309 | + } else |
|
289 | 310 | { |
290 | 311 | include_once $newdir.'/'.$file; |
291 | 312 | } |
@@ -313,7 +334,9 @@ discard block |
||
313 | 334 | foreach ($orders as $key => $value) |
314 | 335 | { |
315 | 336 | $modName = $modules[$key]; |
316 | - if (empty($modName)) continue; |
|
337 | + if (empty($modName)) { |
|
338 | + continue; |
|
339 | + } |
|
317 | 340 | |
318 | 341 | if (! class_exists($modName)) |
319 | 342 | { |
@@ -329,14 +352,19 @@ discard block |
||
329 | 352 | $module=''; |
330 | 353 | |
331 | 354 | // Check if trigger file is disabled by name |
332 | - if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; |
|
355 | + if (preg_match('/NORUN$/i',$files[$key])) { |
|
356 | + $disabledbyname=1; |
|
357 | + } |
|
333 | 358 | // Check if trigger file is for a particular module |
334 | 359 | if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg)) |
335 | 360 | { |
336 | 361 | $module=preg_replace('/^mod/i','',$reg[2]); |
337 | 362 | $constparam='MAIN_MODULE_'.strtoupper($module); |
338 | - if (strtolower($module) == 'all') $disabledbymodule=0; |
|
339 | - else if (empty($conf->global->$constparam)) $disabledbymodule=2; |
|
363 | + if (strtolower($module) == 'all') { |
|
364 | + $disabledbymodule=0; |
|
365 | + } else if (empty($conf->global->$constparam)) { |
|
366 | + $disabledbymodule=2; |
|
367 | + } |
|
340 | 368 | $triggers[$j]['module']=strtolower($module); |
341 | 369 | } |
342 | 370 | |
@@ -348,7 +376,9 @@ discard block |
||
348 | 376 | $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; |
349 | 377 | $triggers[$j]['version'] = $objMod->getVersion(); |
350 | 378 | $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick'); |
351 | - if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; |
|
379 | + if ($disabledbyname > 0 || $disabledbymodule > 1) { |
|
380 | + $triggers[$j]['status'] = ''; |
|
381 | + } |
|
352 | 382 | |
353 | 383 | $text ='<b>'.$langs->trans("Description").':</b><br>'; |
354 | 384 | $text.=$objMod->getDesc().'<br>'; |
@@ -356,13 +386,20 @@ discard block |
||
356 | 386 | if ($disabledbyname == 1) |
357 | 387 | { |
358 | 388 | $text.=$langs->trans("TriggerDisabledByName").'<br>'; |
359 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
360 | - } |
|
361 | - else |
|
389 | + if ($disabledbymodule == 2) { |
|
390 | + $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
391 | + } |
|
392 | + } else |
|
362 | 393 | { |
363 | - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>'; |
|
364 | - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>'; |
|
365 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
394 | + if ($disabledbymodule == 0) { |
|
395 | + $text.=$langs->trans("TriggerAlwaysActive").'<br>'; |
|
396 | + } |
|
397 | + if ($disabledbymodule == 1) { |
|
398 | + $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>'; |
|
399 | + } |
|
400 | + if ($disabledbymodule == 2) { |
|
401 | + $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
402 | + } |
|
366 | 403 | } |
367 | 404 | |
368 | 405 | $triggers[$j]['info'] = $text; |
@@ -26,63 +26,63 @@ |
||
26 | 26 | */ |
27 | 27 | class GoogleAPI |
28 | 28 | { |
29 | - /** |
|
29 | + /** |
|
30 | 30 | * @var DoliDB Database handler. |
31 | 31 | */ |
32 | 32 | public $db; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string Error code (or message) |
|
36 | - */ |
|
37 | - public $error=''; |
|
34 | + /** |
|
35 | + * @var string Error code (or message) |
|
36 | + */ |
|
37 | + public $error=''; |
|
38 | 38 | |
39 | - public $key; |
|
39 | + public $key; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
44 | - * @param DoliDB $db Database handler |
|
45 | - * @param string $key Google key |
|
46 | - */ |
|
47 | - function __construct($db,$key) |
|
48 | - { |
|
49 | - $this->db=$db; |
|
50 | - $this->key=$key; |
|
51 | - } |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | + * @param DoliDB $db Database handler |
|
45 | + * @param string $key Google key |
|
46 | + */ |
|
47 | + function __construct($db,$key) |
|
48 | + { |
|
49 | + $this->db=$db; |
|
50 | + $this->key=$key; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Return geo coordinates of an address |
|
56 | - * |
|
57 | - * @param string $address Address |
|
58 | - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
59 | - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
60 | - * @return string Coordinates |
|
61 | - */ |
|
62 | - function getGeoCoordinatesOfAddress($address) |
|
63 | - { |
|
64 | - global $conf; |
|
54 | + /** |
|
55 | + * Return geo coordinates of an address |
|
56 | + * |
|
57 | + * @param string $address Address |
|
58 | + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
59 | + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
60 | + * @return string Coordinates |
|
61 | + */ |
|
62 | + function getGeoCoordinatesOfAddress($address) |
|
63 | + { |
|
64 | + global $conf; |
|
65 | 65 | |
66 | - $i=0; |
|
66 | + $i=0; |
|
67 | 67 | |
68 | - // Desired address |
|
69 | - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
68 | + // Desired address |
|
69 | + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
70 | 70 | |
71 | - // Retrieve the URL contents |
|
72 | - $page = file_get_contents($urladdress); |
|
71 | + // Retrieve the URL contents |
|
72 | + $page = file_get_contents($urladdress); |
|
73 | 73 | |
74 | - $code = strstr($page, '<coordinates>'); |
|
75 | - $code = strstr($code, '>'); |
|
76 | - $val=strpos($code, "<"); |
|
77 | - $code = substr($code, 1, $val-1); |
|
78 | - //print $code; |
|
79 | - //print "<br>"; |
|
80 | - $latitude = substr($code, 0, strpos($code, ",")); |
|
81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
74 | + $code = strstr($page, '<coordinates>'); |
|
75 | + $code = strstr($code, '>'); |
|
76 | + $val=strpos($code, "<"); |
|
77 | + $code = substr($code, 1, $val-1); |
|
78 | + //print $code; |
|
79 | + //print "<br>"; |
|
80 | + $latitude = substr($code, 0, strpos($code, ",")); |
|
81 | + $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
82 | 82 | |
83 | - // Output the coordinates |
|
84 | - //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
83 | + // Output the coordinates |
|
84 | + //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
85 | 85 | |
86 | - $i++; |
|
87 | - } |
|
86 | + $i++; |
|
87 | + } |
|
88 | 88 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var string Error code (or message) |
36 | 36 | */ |
37 | - public $error=''; |
|
37 | + public $error = ''; |
|
38 | 38 | |
39 | 39 | public $key; |
40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @param DoliDB $db Database handler |
45 | 45 | * @param string $key Google key |
46 | 46 | */ |
47 | - function __construct($db,$key) |
|
47 | + function __construct($db, $key) |
|
48 | 48 | { |
49 | - $this->db=$db; |
|
50 | - $this->key=$key; |
|
49 | + $this->db = $db; |
|
50 | + $this->key = $key; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | global $conf; |
65 | 65 | |
66 | - $i=0; |
|
66 | + $i = 0; |
|
67 | 67 | |
68 | 68 | // Desired address |
69 | 69 | $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | |
74 | 74 | $code = strstr($page, '<coordinates>'); |
75 | 75 | $code = strstr($code, '>'); |
76 | - $val=strpos($code, "<"); |
|
77 | - $code = substr($code, 1, $val-1); |
|
76 | + $val = strpos($code, "<"); |
|
77 | + $code = substr($code, 1, $val - 1); |
|
78 | 78 | //print $code; |
79 | 79 | //print "<br>"; |
80 | 80 | $latitude = substr($code, 0, strpos($code, ",")); |
81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
81 | + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); |
|
82 | 82 | |
83 | 83 | // Output the coordinates |
84 | 84 | //echo "Longitude: $longitude ',' Latitude: $latitude"; |
@@ -61,624 +61,624 @@ discard block |
||
61 | 61 | */ |
62 | 62 | const TYPE_SITUATION = 5; |
63 | 63 | |
64 | - /** |
|
65 | - * Draft status |
|
66 | - */ |
|
67 | - const STATUS_DRAFT = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * Validated (need to be paid) |
|
71 | - */ |
|
72 | - const STATUS_VALIDATED = 1; |
|
73 | - |
|
74 | - /** |
|
75 | - * Classified paid. |
|
76 | - * If paid partially, $this->close_code can be: |
|
77 | - * - CLOSECODE_DISCOUNTVAT |
|
78 | - * - CLOSECODE_BADDEBT |
|
79 | - * If paid completelly, this->close_code will be null |
|
80 | - */ |
|
81 | - const STATUS_CLOSED = 2; |
|
82 | - |
|
83 | - /** |
|
84 | - * Classified abandoned and no payment done. |
|
85 | - * $this->close_code can be: |
|
86 | - * - CLOSECODE_BADDEBT |
|
87 | - * - CLOSECODE_ABANDONED |
|
88 | - * - CLOSECODE_REPLACED |
|
89 | - */ |
|
90 | - const STATUS_ABANDONED = 3; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Return remain amount to pay. Property ->id and ->total_ttc must be set. |
|
95 | - * This does not include open direct debit requests. |
|
96 | - * |
|
97 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
98 | - * @return double Remain of amount to pay |
|
99 | - */ |
|
100 | - function getRemainToPay($multicurrency=0) |
|
101 | - { |
|
102 | - $alreadypaid=0; |
|
103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
106 | - return $this->total_ttc - $alreadypaid; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Return amount of payments already done |
|
111 | - * |
|
112 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
113 | - * @return int Amount of payment already done, <0 if KO |
|
114 | - */ |
|
115 | - function getSommePaiement($multicurrency=0) |
|
116 | - { |
|
117 | - $table='paiement_facture'; |
|
118 | - $field='fk_facture'; |
|
119 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
120 | - { |
|
121 | - $table='paiementfourn_facturefourn'; |
|
122 | - $field='fk_facturefourn'; |
|
123 | - } |
|
124 | - |
|
125 | - $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
|
126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
128 | - |
|
129 | - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
130 | - $resql=$this->db->query($sql); |
|
131 | - if ($resql) |
|
132 | - { |
|
133 | - $obj = $this->db->fetch_object($resql); |
|
134 | - $this->db->free($resql); |
|
135 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
136 | - else return $obj->amount; |
|
137 | - } |
|
138 | - else |
|
139 | - { |
|
140 | - $this->error=$this->db->lasterror(); |
|
141 | - return -1; |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Return amount (with tax) of all deposits invoices used by invoice. |
|
64 | + /** |
|
65 | + * Draft status |
|
66 | + */ |
|
67 | + const STATUS_DRAFT = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * Validated (need to be paid) |
|
71 | + */ |
|
72 | + const STATUS_VALIDATED = 1; |
|
73 | + |
|
74 | + /** |
|
75 | + * Classified paid. |
|
76 | + * If paid partially, $this->close_code can be: |
|
77 | + * - CLOSECODE_DISCOUNTVAT |
|
78 | + * - CLOSECODE_BADDEBT |
|
79 | + * If paid completelly, this->close_code will be null |
|
80 | + */ |
|
81 | + const STATUS_CLOSED = 2; |
|
82 | + |
|
83 | + /** |
|
84 | + * Classified abandoned and no payment done. |
|
85 | + * $this->close_code can be: |
|
86 | + * - CLOSECODE_BADDEBT |
|
87 | + * - CLOSECODE_ABANDONED |
|
88 | + * - CLOSECODE_REPLACED |
|
89 | + */ |
|
90 | + const STATUS_ABANDONED = 3; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Return remain amount to pay. Property ->id and ->total_ttc must be set. |
|
95 | + * This does not include open direct debit requests. |
|
96 | + * |
|
97 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
98 | + * @return double Remain of amount to pay |
|
99 | + */ |
|
100 | + function getRemainToPay($multicurrency=0) |
|
101 | + { |
|
102 | + $alreadypaid=0; |
|
103 | + $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
104 | + $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
105 | + $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
106 | + return $this->total_ttc - $alreadypaid; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Return amount of payments already done |
|
111 | + * |
|
112 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
113 | + * @return int Amount of payment already done, <0 if KO |
|
114 | + */ |
|
115 | + function getSommePaiement($multicurrency=0) |
|
116 | + { |
|
117 | + $table='paiement_facture'; |
|
118 | + $field='fk_facture'; |
|
119 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
120 | + { |
|
121 | + $table='paiementfourn_facturefourn'; |
|
122 | + $field='fk_facturefourn'; |
|
123 | + } |
|
124 | + |
|
125 | + $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
|
126 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | + $sql.= ' WHERE '.$field.' = '.$this->id; |
|
128 | + |
|
129 | + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
130 | + $resql=$this->db->query($sql); |
|
131 | + if ($resql) |
|
132 | + { |
|
133 | + $obj = $this->db->fetch_object($resql); |
|
134 | + $this->db->free($resql); |
|
135 | + if ($multicurrency) return $obj->multicurrency_amount; |
|
136 | + else return $obj->amount; |
|
137 | + } |
|
138 | + else |
|
139 | + { |
|
140 | + $this->error=$this->db->lasterror(); |
|
141 | + return -1; |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Return amount (with tax) of all deposits invoices used by invoice. |
|
147 | 147 | * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). |
148 | - * |
|
149 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
150 | - * @return int <0 if KO, Sum of deposits amount otherwise |
|
151 | - */ |
|
152 | - function getSumDepositsUsed($multicurrency=0) |
|
153 | - { |
|
154 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
155 | - { |
|
156 | - // TODO |
|
157 | - return 0; |
|
158 | - } |
|
159 | - |
|
160 | - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
161 | - |
|
162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
164 | - if ($result >= 0) |
|
165 | - { |
|
166 | - return $result; |
|
167 | - } |
|
168 | - else |
|
169 | - { |
|
170 | - $this->error=$discountstatic->error; |
|
171 | - return -1; |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Return amount (with tax) of all credit notes invoices + excess received used by invoice |
|
177 | - * |
|
178 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
179 | - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
|
180 | - */ |
|
181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
182 | - { |
|
183 | - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
184 | - |
|
185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
187 | - if ($result >= 0) |
|
188 | - { |
|
189 | - return $result; |
|
190 | - } |
|
191 | - else |
|
192 | - { |
|
193 | - $this->error=$discountstatic->error; |
|
194 | - return -1; |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Renvoie tableau des ids de facture avoir issus de la facture |
|
200 | - * |
|
201 | - * @return array Tableau d'id de factures avoirs |
|
202 | - */ |
|
203 | - function getListIdAvoirFromInvoice() |
|
204 | - { |
|
205 | - $idarray=array(); |
|
206 | - |
|
207 | - $sql = 'SELECT rowid'; |
|
208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
210 | - $sql.= ' AND type = 2'; |
|
211 | - $resql=$this->db->query($sql); |
|
212 | - if ($resql) |
|
213 | - { |
|
214 | - $num = $this->db->num_rows($resql); |
|
215 | - $i = 0; |
|
216 | - while ($i < $num) |
|
217 | - { |
|
218 | - $row = $this->db->fetch_row($resql); |
|
219 | - $idarray[]=$row[0]; |
|
220 | - $i++; |
|
221 | - } |
|
222 | - } |
|
223 | - else |
|
224 | - { |
|
225 | - dol_print_error($this->db); |
|
226 | - } |
|
227 | - return $idarray; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Renvoie l'id de la facture qui la remplace |
|
232 | - * |
|
233 | - * @param string $option filtre sur statut ('', 'validated', ...) |
|
234 | - * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
|
235 | - */ |
|
236 | - function getIdReplacingInvoice($option='') |
|
237 | - { |
|
238 | - $sql = 'SELECT rowid'; |
|
239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
241 | - $sql.= ' AND type < 2'; |
|
242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
243 | - // PROTECTION BAD DATA |
|
244 | - // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
|
245 | - // et une autre non, on donne priorite a la validee. |
|
246 | - // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
|
247 | - // ont cree en meme temps une facture de remplacement pour la meme facture) |
|
248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
249 | - |
|
250 | - $resql=$this->db->query($sql); |
|
251 | - if ($resql) |
|
252 | - { |
|
253 | - $obj = $this->db->fetch_object($resql); |
|
254 | - if ($obj) |
|
255 | - { |
|
256 | - // Si il y en a |
|
257 | - return $obj->rowid; |
|
258 | - } |
|
259 | - else |
|
260 | - { |
|
261 | - // Si aucune facture ne remplace |
|
262 | - return 0; |
|
263 | - } |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - return -1; |
|
268 | - } |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Return list of payments |
|
273 | - * |
|
274 | - * @param string $filtertype 1 to filter on type of payment == 'PRE' |
|
275 | - * @return array Array with list of payments |
|
276 | - */ |
|
277 | - function getListOfPayments($filtertype='') |
|
278 | - { |
|
279 | - $retarray=array(); |
|
280 | - |
|
281 | - $table='paiement_facture'; |
|
282 | - $table2='paiement'; |
|
283 | - $field='fk_facture'; |
|
284 | - $field2='fk_paiement'; |
|
285 | - $sharedentity='facture'; |
|
286 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
287 | - { |
|
288 | - $table='paiementfourn_facturefourn'; |
|
289 | - $table2='paiementfourn'; |
|
290 | - $field='fk_facturefourn'; |
|
291 | - $field2='fk_paiementfourn'; |
|
292 | - $sharedentity='facture_fourn'; |
|
293 | - } |
|
294 | - |
|
295 | - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
|
296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
298 | - //$sql.= ' WHERE pf.'.$field.' = 1'; |
|
299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
303 | - |
|
304 | - dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
|
305 | - $resql=$this->db->query($sql); |
|
306 | - if ($resql) |
|
307 | - { |
|
308 | - $num = $this->db->num_rows($resql); |
|
309 | - $i=0; |
|
310 | - while ($i < $num) |
|
311 | - { |
|
312 | - $obj = $this->db->fetch_object($resql); |
|
313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
314 | - $i++; |
|
315 | - } |
|
316 | - $this->db->free($resql); |
|
317 | - return $retarray; |
|
318 | - } |
|
319 | - else |
|
320 | - { |
|
321 | - $this->error=$this->db->lasterror(); |
|
322 | - dol_print_error($this->db); |
|
323 | - return array(); |
|
324 | - } |
|
325 | - } |
|
148 | + * |
|
149 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
150 | + * @return int <0 if KO, Sum of deposits amount otherwise |
|
151 | + */ |
|
152 | + function getSumDepositsUsed($multicurrency=0) |
|
153 | + { |
|
154 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
155 | + { |
|
156 | + // TODO |
|
157 | + return 0; |
|
158 | + } |
|
159 | + |
|
160 | + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
161 | + |
|
162 | + $discountstatic=new DiscountAbsolute($this->db); |
|
163 | + $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
164 | + if ($result >= 0) |
|
165 | + { |
|
166 | + return $result; |
|
167 | + } |
|
168 | + else |
|
169 | + { |
|
170 | + $this->error=$discountstatic->error; |
|
171 | + return -1; |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Return amount (with tax) of all credit notes invoices + excess received used by invoice |
|
177 | + * |
|
178 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
179 | + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
|
180 | + */ |
|
181 | + function getSumCreditNotesUsed($multicurrency=0) |
|
182 | + { |
|
183 | + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
184 | + |
|
185 | + $discountstatic=new DiscountAbsolute($this->db); |
|
186 | + $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
187 | + if ($result >= 0) |
|
188 | + { |
|
189 | + return $result; |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
193 | + $this->error=$discountstatic->error; |
|
194 | + return -1; |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Renvoie tableau des ids de facture avoir issus de la facture |
|
200 | + * |
|
201 | + * @return array Tableau d'id de factures avoirs |
|
202 | + */ |
|
203 | + function getListIdAvoirFromInvoice() |
|
204 | + { |
|
205 | + $idarray=array(); |
|
206 | + |
|
207 | + $sql = 'SELECT rowid'; |
|
208 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | + $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
210 | + $sql.= ' AND type = 2'; |
|
211 | + $resql=$this->db->query($sql); |
|
212 | + if ($resql) |
|
213 | + { |
|
214 | + $num = $this->db->num_rows($resql); |
|
215 | + $i = 0; |
|
216 | + while ($i < $num) |
|
217 | + { |
|
218 | + $row = $this->db->fetch_row($resql); |
|
219 | + $idarray[]=$row[0]; |
|
220 | + $i++; |
|
221 | + } |
|
222 | + } |
|
223 | + else |
|
224 | + { |
|
225 | + dol_print_error($this->db); |
|
226 | + } |
|
227 | + return $idarray; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Renvoie l'id de la facture qui la remplace |
|
232 | + * |
|
233 | + * @param string $option filtre sur statut ('', 'validated', ...) |
|
234 | + * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
|
235 | + */ |
|
236 | + function getIdReplacingInvoice($option='') |
|
237 | + { |
|
238 | + $sql = 'SELECT rowid'; |
|
239 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | + $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
241 | + $sql.= ' AND type < 2'; |
|
242 | + if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
243 | + // PROTECTION BAD DATA |
|
244 | + // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
|
245 | + // et une autre non, on donne priorite a la validee. |
|
246 | + // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
|
247 | + // ont cree en meme temps une facture de remplacement pour la meme facture) |
|
248 | + $sql.= ' ORDER BY fk_statut DESC'; |
|
249 | + |
|
250 | + $resql=$this->db->query($sql); |
|
251 | + if ($resql) |
|
252 | + { |
|
253 | + $obj = $this->db->fetch_object($resql); |
|
254 | + if ($obj) |
|
255 | + { |
|
256 | + // Si il y en a |
|
257 | + return $obj->rowid; |
|
258 | + } |
|
259 | + else |
|
260 | + { |
|
261 | + // Si aucune facture ne remplace |
|
262 | + return 0; |
|
263 | + } |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + return -1; |
|
268 | + } |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Return list of payments |
|
273 | + * |
|
274 | + * @param string $filtertype 1 to filter on type of payment == 'PRE' |
|
275 | + * @return array Array with list of payments |
|
276 | + */ |
|
277 | + function getListOfPayments($filtertype='') |
|
278 | + { |
|
279 | + $retarray=array(); |
|
280 | + |
|
281 | + $table='paiement_facture'; |
|
282 | + $table2='paiement'; |
|
283 | + $field='fk_facture'; |
|
284 | + $field2='fk_paiement'; |
|
285 | + $sharedentity='facture'; |
|
286 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
287 | + { |
|
288 | + $table='paiementfourn_facturefourn'; |
|
289 | + $table2='paiementfourn'; |
|
290 | + $field='fk_facturefourn'; |
|
291 | + $field2='fk_paiementfourn'; |
|
292 | + $sharedentity='facture_fourn'; |
|
293 | + } |
|
294 | + |
|
295 | + $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
|
296 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | + $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
298 | + //$sql.= ' WHERE pf.'.$field.' = 1'; |
|
299 | + $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | + $sql.= ' AND p.fk_paiement = t.id'; |
|
301 | + $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
302 | + if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
303 | + |
|
304 | + dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
|
305 | + $resql=$this->db->query($sql); |
|
306 | + if ($resql) |
|
307 | + { |
|
308 | + $num = $this->db->num_rows($resql); |
|
309 | + $i=0; |
|
310 | + while ($i < $num) |
|
311 | + { |
|
312 | + $obj = $this->db->fetch_object($resql); |
|
313 | + $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
314 | + $i++; |
|
315 | + } |
|
316 | + $this->db->free($resql); |
|
317 | + return $retarray; |
|
318 | + } |
|
319 | + else |
|
320 | + { |
|
321 | + $this->error=$this->db->lasterror(); |
|
322 | + dol_print_error($this->db); |
|
323 | + return array(); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | |
328 | 328 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
329 | - /** |
|
330 | - * Return if an invoice can be deleted |
|
331 | - * Rule is: |
|
332 | - * If invoice is draft and has a temporary ref -> yes (1) |
|
333 | - * If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0) |
|
334 | - * If invoice is dispatched in bookkeeping -> no (-1) |
|
335 | - * If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2) |
|
336 | - * If invoice not last in a cycle -> no (-3) |
|
337 | - * If there is payment -> no (-4) |
|
338 | - * Otherwise -> yes (2) |
|
339 | - * |
|
340 | - * @return int <=0 if no, >0 if yes |
|
341 | - */ |
|
342 | - function is_erasable() |
|
343 | - { |
|
329 | + /** |
|
330 | + * Return if an invoice can be deleted |
|
331 | + * Rule is: |
|
332 | + * If invoice is draft and has a temporary ref -> yes (1) |
|
333 | + * If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0) |
|
334 | + * If invoice is dispatched in bookkeeping -> no (-1) |
|
335 | + * If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2) |
|
336 | + * If invoice not last in a cycle -> no (-3) |
|
337 | + * If there is payment -> no (-4) |
|
338 | + * Otherwise -> yes (2) |
|
339 | + * |
|
340 | + * @return int <=0 if no, >0 if yes |
|
341 | + */ |
|
342 | + function is_erasable() |
|
343 | + { |
|
344 | 344 | // phpcs:enable |
345 | - global $conf; |
|
346 | - |
|
347 | - // We check if invoice is a temporary number (PROVxxxx) |
|
348 | - $tmppart = substr($this->ref, 1, 4); |
|
349 | - |
|
350 | - if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
351 | - { |
|
352 | - return 1; |
|
353 | - } |
|
354 | - |
|
355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
356 | - |
|
357 | - // If not a draft invoice and not temporary invoice |
|
358 | - if ($tmppart !== 'PROV') |
|
359 | - { |
|
360 | - $ventilExportCompta = $this->getVentilExportCompta(); |
|
361 | - if ($ventilExportCompta != 0) return -1; |
|
362 | - |
|
363 | - // Get last number of validated invoice |
|
364 | - if ($this->element != 'invoice_supplier') |
|
365 | - { |
|
366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
368 | - |
|
369 | - // If there is no invoice into the reset range and not already dispatched, we can delete |
|
370 | - // If invoice to delete is last one and not already dispatched, we can delete |
|
371 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
372 | - |
|
373 | - // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
|
374 | - // ... |
|
375 | - |
|
376 | - if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
|
377 | - { |
|
378 | - $last = $this->is_last_in_cycle(); |
|
379 | - if (! $last) return -3; |
|
380 | - } |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - // Test if there is at least one payment. If yes, refuse to delete. |
|
385 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
386 | - |
|
387 | - return 2; |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * Return if an invoice was dispatched into bookkeeping |
|
392 | - * |
|
393 | - * @return int <0 if KO, 0=no, 1=yes |
|
394 | - */ |
|
395 | - public function getVentilExportCompta() |
|
396 | - { |
|
397 | - $alreadydispatched = 0; |
|
398 | - |
|
399 | - $type = 'customer_invoice'; |
|
400 | - if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
401 | - |
|
402 | - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
|
403 | - $resql = $this->db->query($sql); |
|
404 | - if ($resql) |
|
405 | - { |
|
406 | - $obj = $this->db->fetch_object($resql); |
|
407 | - if ($obj) |
|
408 | - { |
|
409 | - $alreadydispatched = $obj->nb; |
|
410 | - } |
|
411 | - } |
|
412 | - else |
|
413 | - { |
|
414 | - $this->error = $this->db->lasterror(); |
|
415 | - return -1; |
|
416 | - } |
|
417 | - |
|
418 | - if ($alreadydispatched) |
|
419 | - { |
|
420 | - return 1; |
|
421 | - } |
|
422 | - return 0; |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * Return label of type of invoice |
|
428 | - * |
|
429 | - * @return string Label of type of invoice |
|
430 | - */ |
|
431 | - function getLibType() |
|
432 | - { |
|
433 | - global $langs; |
|
345 | + global $conf; |
|
346 | + |
|
347 | + // We check if invoice is a temporary number (PROVxxxx) |
|
348 | + $tmppart = substr($this->ref, 1, 4); |
|
349 | + |
|
350 | + if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
351 | + { |
|
352 | + return 1; |
|
353 | + } |
|
354 | + |
|
355 | + if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
356 | + |
|
357 | + // If not a draft invoice and not temporary invoice |
|
358 | + if ($tmppart !== 'PROV') |
|
359 | + { |
|
360 | + $ventilExportCompta = $this->getVentilExportCompta(); |
|
361 | + if ($ventilExportCompta != 0) return -1; |
|
362 | + |
|
363 | + // Get last number of validated invoice |
|
364 | + if ($this->element != 'invoice_supplier') |
|
365 | + { |
|
366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | + $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
368 | + |
|
369 | + // If there is no invoice into the reset range and not already dispatched, we can delete |
|
370 | + // If invoice to delete is last one and not already dispatched, we can delete |
|
371 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
372 | + |
|
373 | + // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
|
374 | + // ... |
|
375 | + |
|
376 | + if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
|
377 | + { |
|
378 | + $last = $this->is_last_in_cycle(); |
|
379 | + if (! $last) return -3; |
|
380 | + } |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + // Test if there is at least one payment. If yes, refuse to delete. |
|
385 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
386 | + |
|
387 | + return 2; |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * Return if an invoice was dispatched into bookkeeping |
|
392 | + * |
|
393 | + * @return int <0 if KO, 0=no, 1=yes |
|
394 | + */ |
|
395 | + public function getVentilExportCompta() |
|
396 | + { |
|
397 | + $alreadydispatched = 0; |
|
398 | + |
|
399 | + $type = 'customer_invoice'; |
|
400 | + if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
401 | + |
|
402 | + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
|
403 | + $resql = $this->db->query($sql); |
|
404 | + if ($resql) |
|
405 | + { |
|
406 | + $obj = $this->db->fetch_object($resql); |
|
407 | + if ($obj) |
|
408 | + { |
|
409 | + $alreadydispatched = $obj->nb; |
|
410 | + } |
|
411 | + } |
|
412 | + else |
|
413 | + { |
|
414 | + $this->error = $this->db->lasterror(); |
|
415 | + return -1; |
|
416 | + } |
|
417 | + |
|
418 | + if ($alreadydispatched) |
|
419 | + { |
|
420 | + return 1; |
|
421 | + } |
|
422 | + return 0; |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * Return label of type of invoice |
|
428 | + * |
|
429 | + * @return string Label of type of invoice |
|
430 | + */ |
|
431 | + function getLibType() |
|
432 | + { |
|
433 | + global $langs; |
|
434 | 434 | if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); |
435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
438 | 438 | elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
440 | - return $langs->trans("Unknown"); |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * Return label of object status |
|
445 | - * |
|
446 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
447 | - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
448 | - * @return string Label of status |
|
449 | - */ |
|
450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
451 | - { |
|
452 | - return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
|
453 | - } |
|
440 | + return $langs->trans("Unknown"); |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Return label of object status |
|
445 | + * |
|
446 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
447 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
448 | + * @return string Label of status |
|
449 | + */ |
|
450 | + function getLibStatut($mode=0, $alreadypaid=-1) |
|
451 | + { |
|
452 | + return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
|
453 | + } |
|
454 | 454 | |
455 | 455 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
456 | - /** |
|
457 | - * Return label of a status |
|
458 | - * |
|
459 | - * @param int $paye Status field paye |
|
460 | - * @param int $status Id status |
|
461 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto |
|
462 | - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) |
|
463 | - * @param int $type Type invoice |
|
464 | - * @return string Label of status |
|
465 | - */ |
|
466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
467 | - { |
|
456 | + /** |
|
457 | + * Return label of a status |
|
458 | + * |
|
459 | + * @param int $paye Status field paye |
|
460 | + * @param int $status Id status |
|
461 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto |
|
462 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) |
|
463 | + * @param int $type Type invoice |
|
464 | + * @return string Label of status |
|
465 | + */ |
|
466 | + function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
467 | + { |
|
468 | 468 | // phpcs:enable |
469 | - global $langs; |
|
470 | - $langs->load('bills'); |
|
471 | - |
|
472 | - //print "$paye,$status,$mode,$alreadypaid,$type"; |
|
473 | - if ($mode == 0) |
|
474 | - { |
|
475 | - $prefix=''; |
|
476 | - if (! $paye) |
|
477 | - { |
|
478 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
479 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
480 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
481 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
482 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
483 | - } |
|
484 | - else |
|
485 | - { |
|
486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
489 | - } |
|
490 | - } |
|
491 | - elseif ($mode == 1) |
|
492 | - { |
|
493 | - $prefix='Short'; |
|
494 | - if (! $paye) |
|
495 | - { |
|
496 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
497 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
498 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
499 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
500 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
501 | - } |
|
502 | - else |
|
503 | - { |
|
504 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
505 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
506 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
507 | - } |
|
508 | - } |
|
509 | - elseif ($mode == 2) |
|
510 | - { |
|
511 | - $prefix='Short'; |
|
512 | - if (! $paye) |
|
513 | - { |
|
514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | - } |
|
520 | - else |
|
521 | - { |
|
522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
525 | - } |
|
526 | - } |
|
527 | - elseif ($mode == 3) |
|
528 | - { |
|
529 | - $prefix='Short'; |
|
530 | - if (! $paye) |
|
531 | - { |
|
532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
537 | - } |
|
538 | - else |
|
539 | - { |
|
540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
543 | - } |
|
544 | - } |
|
545 | - elseif ($mode == 4) |
|
546 | - { |
|
547 | - $prefix=''; |
|
548 | - if (! $paye) |
|
549 | - { |
|
550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | - } |
|
556 | - else |
|
557 | - { |
|
558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
561 | - } |
|
562 | - } |
|
563 | - elseif ($mode == 5 || $mode == 6) |
|
564 | - { |
|
565 | - $prefix=''; |
|
566 | - if ($mode == 5) $prefix='Short'; |
|
567 | - if (! $paye) |
|
568 | - { |
|
569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
572 | - elseif ($alreadypaid <= 0) |
|
573 | - { |
|
574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
576 | - } |
|
577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
578 | - } |
|
579 | - else |
|
580 | - { |
|
581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
584 | - } |
|
585 | - } |
|
586 | - } |
|
469 | + global $langs; |
|
470 | + $langs->load('bills'); |
|
471 | + |
|
472 | + //print "$paye,$status,$mode,$alreadypaid,$type"; |
|
473 | + if ($mode == 0) |
|
474 | + { |
|
475 | + $prefix=''; |
|
476 | + if (! $paye) |
|
477 | + { |
|
478 | + if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
479 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
480 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
481 | + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
482 | + else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
483 | + } |
|
484 | + else |
|
485 | + { |
|
486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | + else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
489 | + } |
|
490 | + } |
|
491 | + elseif ($mode == 1) |
|
492 | + { |
|
493 | + $prefix='Short'; |
|
494 | + if (! $paye) |
|
495 | + { |
|
496 | + if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
497 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
498 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
499 | + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
500 | + else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
501 | + } |
|
502 | + else |
|
503 | + { |
|
504 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
505 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
506 | + else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
507 | + } |
|
508 | + } |
|
509 | + elseif ($mode == 2) |
|
510 | + { |
|
511 | + $prefix='Short'; |
|
512 | + if (! $paye) |
|
513 | + { |
|
514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | + } |
|
520 | + else |
|
521 | + { |
|
522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
525 | + } |
|
526 | + } |
|
527 | + elseif ($mode == 3) |
|
528 | + { |
|
529 | + $prefix='Short'; |
|
530 | + if (! $paye) |
|
531 | + { |
|
532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
537 | + } |
|
538 | + else |
|
539 | + { |
|
540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
543 | + } |
|
544 | + } |
|
545 | + elseif ($mode == 4) |
|
546 | + { |
|
547 | + $prefix=''; |
|
548 | + if (! $paye) |
|
549 | + { |
|
550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | + } |
|
556 | + else |
|
557 | + { |
|
558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
561 | + } |
|
562 | + } |
|
563 | + elseif ($mode == 5 || $mode == 6) |
|
564 | + { |
|
565 | + $prefix=''; |
|
566 | + if ($mode == 5) $prefix='Short'; |
|
567 | + if (! $paye) |
|
568 | + { |
|
569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
572 | + elseif ($alreadypaid <= 0) |
|
573 | + { |
|
574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
576 | + } |
|
577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
578 | + } |
|
579 | + else |
|
580 | + { |
|
581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
584 | + } |
|
585 | + } |
|
586 | + } |
|
587 | 587 | |
588 | 588 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
589 | - /** |
|
590 | - * Renvoi une date limite de reglement de facture en fonction des |
|
591 | - * conditions de reglements de la facture et date de facturation. |
|
592 | - * |
|
593 | - * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
|
594 | - * @return date Date limite de reglement si ok, <0 si ko |
|
595 | - */ |
|
596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
597 | - { |
|
589 | + /** |
|
590 | + * Renvoi une date limite de reglement de facture en fonction des |
|
591 | + * conditions de reglements de la facture et date de facturation. |
|
592 | + * |
|
593 | + * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
|
594 | + * @return date Date limite de reglement si ok, <0 si ko |
|
595 | + */ |
|
596 | + function calculate_date_lim_reglement($cond_reglement=0) |
|
597 | + { |
|
598 | 598 | // phpcs:enable |
599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
599 | + if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | + if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
601 | 601 | |
602 | - $cdr_nbjour=0; |
|
602 | + $cdr_nbjour=0; |
|
603 | 603 | $cdr_type=0; |
604 | 604 | $cdr_decalage=0; |
605 | 605 | |
606 | - $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
|
607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
609 | - else { |
|
610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
612 | - } |
|
613 | - |
|
614 | - dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
|
615 | - $resqltemp=$this->db->query($sqltemp); |
|
616 | - if ($resqltemp) |
|
617 | - { |
|
618 | - if ($this->db->num_rows($resqltemp)) |
|
619 | - { |
|
620 | - $obj = $this->db->fetch_object($resqltemp); |
|
621 | - $cdr_nbjour = $obj->nbjour; |
|
622 | - $cdr_type = $obj->type_cdr; |
|
623 | - $cdr_decalage = $obj->decalage; |
|
624 | - } |
|
625 | - } |
|
626 | - else |
|
627 | - { |
|
628 | - $this->error=$this->db->error(); |
|
629 | - return -1; |
|
630 | - } |
|
631 | - $this->db->free($resqltemp); |
|
632 | - |
|
633 | - /* Definition de la date limite */ |
|
634 | - |
|
635 | - // 0 : ajout du nombre de jours |
|
636 | - if ($cdr_type == 0) |
|
637 | - { |
|
638 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
639 | - |
|
640 | - $datelim += ($cdr_decalage * 3600 * 24); |
|
641 | - } |
|
642 | - // 1 : application de la regle "fin de mois" |
|
643 | - elseif ($cdr_type == 1) |
|
644 | - { |
|
645 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
646 | - |
|
647 | - $mois=date('m', $datelim); |
|
648 | - $annee=date('Y', $datelim); |
|
649 | - if ($mois == 12) |
|
650 | - { |
|
651 | - $mois = 1; |
|
652 | - $annee += 1; |
|
653 | - } |
|
654 | - else |
|
655 | - { |
|
656 | - $mois += 1; |
|
657 | - } |
|
658 | - // On se deplace au debut du mois suivant, et on retire un jour |
|
659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
660 | - $datelim -= (3600 * 24); |
|
661 | - |
|
662 | - $datelim += ($cdr_decalage * 3600 * 24); |
|
663 | - } |
|
664 | - // 2 : application de la règle, le N du mois courant ou suivant |
|
665 | - elseif ($cdr_type == 2 && !empty($cdr_decalage)) |
|
666 | - { |
|
667 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
668 | - |
|
669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
670 | - $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
|
671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
672 | - |
|
673 | - $diff = $date_piece - $date_lim_current; |
|
674 | - |
|
675 | - if ($diff < 0) $datelim = $date_lim_current; |
|
676 | - else $datelim = $date_lim_next; |
|
677 | - } |
|
678 | - else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
679 | - |
|
680 | - return $datelim; |
|
681 | - } |
|
606 | + $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
|
607 | + $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | + if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
609 | + else { |
|
610 | + $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | + $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
612 | + } |
|
613 | + |
|
614 | + dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
|
615 | + $resqltemp=$this->db->query($sqltemp); |
|
616 | + if ($resqltemp) |
|
617 | + { |
|
618 | + if ($this->db->num_rows($resqltemp)) |
|
619 | + { |
|
620 | + $obj = $this->db->fetch_object($resqltemp); |
|
621 | + $cdr_nbjour = $obj->nbjour; |
|
622 | + $cdr_type = $obj->type_cdr; |
|
623 | + $cdr_decalage = $obj->decalage; |
|
624 | + } |
|
625 | + } |
|
626 | + else |
|
627 | + { |
|
628 | + $this->error=$this->db->error(); |
|
629 | + return -1; |
|
630 | + } |
|
631 | + $this->db->free($resqltemp); |
|
632 | + |
|
633 | + /* Definition de la date limite */ |
|
634 | + |
|
635 | + // 0 : ajout du nombre de jours |
|
636 | + if ($cdr_type == 0) |
|
637 | + { |
|
638 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
639 | + |
|
640 | + $datelim += ($cdr_decalage * 3600 * 24); |
|
641 | + } |
|
642 | + // 1 : application de la regle "fin de mois" |
|
643 | + elseif ($cdr_type == 1) |
|
644 | + { |
|
645 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
646 | + |
|
647 | + $mois=date('m', $datelim); |
|
648 | + $annee=date('Y', $datelim); |
|
649 | + if ($mois == 12) |
|
650 | + { |
|
651 | + $mois = 1; |
|
652 | + $annee += 1; |
|
653 | + } |
|
654 | + else |
|
655 | + { |
|
656 | + $mois += 1; |
|
657 | + } |
|
658 | + // On se deplace au debut du mois suivant, et on retire un jour |
|
659 | + $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
660 | + $datelim -= (3600 * 24); |
|
661 | + |
|
662 | + $datelim += ($cdr_decalage * 3600 * 24); |
|
663 | + } |
|
664 | + // 2 : application de la règle, le N du mois courant ou suivant |
|
665 | + elseif ($cdr_type == 2 && !empty($cdr_decalage)) |
|
666 | + { |
|
667 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
668 | + |
|
669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
670 | + $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
|
671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
672 | + |
|
673 | + $diff = $date_piece - $date_lim_current; |
|
674 | + |
|
675 | + if ($diff < 0) $datelim = $date_lim_current; |
|
676 | + else $datelim = $date_lim_next; |
|
677 | + } |
|
678 | + else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
679 | + |
|
680 | + return $datelim; |
|
681 | + } |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -690,105 +690,105 @@ discard block |
||
690 | 690 | */ |
691 | 691 | abstract class CommonInvoiceLine extends CommonObjectLine |
692 | 692 | { |
693 | - /** |
|
694 | - * Quantity |
|
695 | - * @var double |
|
696 | - */ |
|
697 | - public $qty; |
|
698 | - |
|
699 | - /** |
|
700 | - * Unit price before taxes |
|
701 | - * @var float |
|
702 | - */ |
|
703 | - public $subprice; |
|
704 | - |
|
705 | - /** |
|
706 | - * Type of the product. 0 for product 1 for service |
|
707 | - * @var int |
|
708 | - */ |
|
709 | - public $product_type = 0; |
|
710 | - |
|
711 | - /** |
|
712 | - * Id of corresponding product |
|
713 | - * @var int |
|
714 | - */ |
|
715 | - public $fk_product; |
|
716 | - |
|
717 | - /** |
|
718 | - * VAT code |
|
719 | - * @var string |
|
720 | - */ |
|
721 | - public $vat_src_code; |
|
722 | - |
|
723 | - /** |
|
724 | - * VAT % |
|
725 | - * @var float |
|
726 | - */ |
|
727 | - public $tva_tx; |
|
728 | - |
|
729 | - /** |
|
730 | - * Local tax 1 % |
|
731 | - * @var float |
|
732 | - */ |
|
733 | - public $localtax1_tx; |
|
734 | - |
|
735 | - /** |
|
736 | - * Local tax 2 % |
|
737 | - * @var float |
|
738 | - */ |
|
739 | - public $localtax2_tx; |
|
740 | - |
|
741 | - /** |
|
742 | - * Percent of discount |
|
743 | - * @var float |
|
744 | - */ |
|
745 | - public $remise_percent; |
|
746 | - |
|
747 | - /** |
|
748 | - * Total amount before taxes |
|
749 | - * @var float |
|
750 | - */ |
|
751 | - public $total_ht; |
|
752 | - |
|
753 | - /** |
|
754 | - * Total VAT amount |
|
755 | - * @var float |
|
756 | - */ |
|
757 | - public $total_tva; |
|
758 | - |
|
759 | - /** |
|
760 | - * Total local tax 1 amount |
|
761 | - * @var float |
|
762 | - */ |
|
763 | - public $total_localtax1; |
|
764 | - |
|
765 | - /** |
|
766 | - * Total local tax 2 amount |
|
767 | - * @var float |
|
768 | - */ |
|
769 | - public $total_localtax2; |
|
770 | - |
|
771 | - /** |
|
772 | - * Total amount with taxes |
|
773 | - * @var float |
|
774 | - */ |
|
775 | - public $total_ttc; |
|
776 | - |
|
777 | - /** |
|
778 | - * Liste d'options cumulables: |
|
779 | - * Bit 0: 0 si TVA normal - 1 si TVA NPR |
|
780 | - * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) |
|
781 | - * @var int |
|
782 | - */ |
|
783 | - public $info_bits = 0; |
|
784 | - |
|
785 | - /** |
|
786 | - * Constructor |
|
787 | - * |
|
788 | - * @param DoliDB $db Database handler |
|
789 | - */ |
|
790 | - public function __construct(DoliDB $db) |
|
791 | - { |
|
792 | - $this->db = $db; |
|
793 | - } |
|
693 | + /** |
|
694 | + * Quantity |
|
695 | + * @var double |
|
696 | + */ |
|
697 | + public $qty; |
|
698 | + |
|
699 | + /** |
|
700 | + * Unit price before taxes |
|
701 | + * @var float |
|
702 | + */ |
|
703 | + public $subprice; |
|
704 | + |
|
705 | + /** |
|
706 | + * Type of the product. 0 for product 1 for service |
|
707 | + * @var int |
|
708 | + */ |
|
709 | + public $product_type = 0; |
|
710 | + |
|
711 | + /** |
|
712 | + * Id of corresponding product |
|
713 | + * @var int |
|
714 | + */ |
|
715 | + public $fk_product; |
|
716 | + |
|
717 | + /** |
|
718 | + * VAT code |
|
719 | + * @var string |
|
720 | + */ |
|
721 | + public $vat_src_code; |
|
722 | + |
|
723 | + /** |
|
724 | + * VAT % |
|
725 | + * @var float |
|
726 | + */ |
|
727 | + public $tva_tx; |
|
728 | + |
|
729 | + /** |
|
730 | + * Local tax 1 % |
|
731 | + * @var float |
|
732 | + */ |
|
733 | + public $localtax1_tx; |
|
734 | + |
|
735 | + /** |
|
736 | + * Local tax 2 % |
|
737 | + * @var float |
|
738 | + */ |
|
739 | + public $localtax2_tx; |
|
740 | + |
|
741 | + /** |
|
742 | + * Percent of discount |
|
743 | + * @var float |
|
744 | + */ |
|
745 | + public $remise_percent; |
|
746 | + |
|
747 | + /** |
|
748 | + * Total amount before taxes |
|
749 | + * @var float |
|
750 | + */ |
|
751 | + public $total_ht; |
|
752 | + |
|
753 | + /** |
|
754 | + * Total VAT amount |
|
755 | + * @var float |
|
756 | + */ |
|
757 | + public $total_tva; |
|
758 | + |
|
759 | + /** |
|
760 | + * Total local tax 1 amount |
|
761 | + * @var float |
|
762 | + */ |
|
763 | + public $total_localtax1; |
|
764 | + |
|
765 | + /** |
|
766 | + * Total local tax 2 amount |
|
767 | + * @var float |
|
768 | + */ |
|
769 | + public $total_localtax2; |
|
770 | + |
|
771 | + /** |
|
772 | + * Total amount with taxes |
|
773 | + * @var float |
|
774 | + */ |
|
775 | + public $total_ttc; |
|
776 | + |
|
777 | + /** |
|
778 | + * Liste d'options cumulables: |
|
779 | + * Bit 0: 0 si TVA normal - 1 si TVA NPR |
|
780 | + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) |
|
781 | + * @var int |
|
782 | + */ |
|
783 | + public $info_bits = 0; |
|
784 | + |
|
785 | + /** |
|
786 | + * Constructor |
|
787 | + * |
|
788 | + * @param DoliDB $db Database handler |
|
789 | + */ |
|
790 | + public function __construct(DoliDB $db) |
|
791 | + { |
|
792 | + $this->db = $db; |
|
793 | + } |
|
794 | 794 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of the superclass of invoices classes (customer and supplier) |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Superclass for invoices classes |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * @param int $multicurrency Return multicurrency_amount instead of amount |
98 | 98 | * @return double Remain of amount to pay |
99 | 99 | */ |
100 | - function getRemainToPay($multicurrency=0) |
|
100 | + function getRemainToPay($multicurrency = 0) |
|
101 | 101 | { |
102 | - $alreadypaid=0; |
|
103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
102 | + $alreadypaid = 0; |
|
103 | + $alreadypaid += $this->getSommePaiement($multicurrency); |
|
104 | + $alreadypaid += $this->getSumDepositsUsed($multicurrency); |
|
105 | + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); |
|
106 | 106 | return $this->total_ttc - $alreadypaid; |
107 | 107 | } |
108 | 108 | |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | * @param int $multicurrency Return multicurrency_amount instead of amount |
113 | 113 | * @return int Amount of payment already done, <0 if KO |
114 | 114 | */ |
115 | - function getSommePaiement($multicurrency=0) |
|
115 | + function getSommePaiement($multicurrency = 0) |
|
116 | 116 | { |
117 | - $table='paiement_facture'; |
|
118 | - $field='fk_facture'; |
|
117 | + $table = 'paiement_facture'; |
|
118 | + $field = 'fk_facture'; |
|
119 | 119 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
120 | 120 | { |
121 | - $table='paiementfourn_facturefourn'; |
|
122 | - $field='fk_facturefourn'; |
|
121 | + $table = 'paiementfourn_facturefourn'; |
|
122 | + $field = 'fk_facturefourn'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
126 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | + $sql .= ' WHERE '.$field.' = '.$this->id; |
|
128 | 128 | |
129 | 129 | dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
130 | - $resql=$this->db->query($sql); |
|
130 | + $resql = $this->db->query($sql); |
|
131 | 131 | if ($resql) |
132 | 132 | { |
133 | 133 | $obj = $this->db->fetch_object($resql); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - $this->error=$this->db->lasterror(); |
|
140 | + $this->error = $this->db->lasterror(); |
|
141 | 141 | return -1; |
142 | 142 | } |
143 | 143 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param int $multicurrency Return multicurrency_amount instead of amount |
150 | 150 | * @return int <0 if KO, Sum of deposits amount otherwise |
151 | 151 | */ |
152 | - function getSumDepositsUsed($multicurrency=0) |
|
152 | + function getSumDepositsUsed($multicurrency = 0) |
|
153 | 153 | { |
154 | 154 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
155 | 155 | { |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | |
160 | 160 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
161 | 161 | |
162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
162 | + $discountstatic = new DiscountAbsolute($this->db); |
|
163 | + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
164 | 164 | if ($result >= 0) |
165 | 165 | { |
166 | 166 | return $result; |
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | - $this->error=$discountstatic->error; |
|
170 | + $this->error = $discountstatic->error; |
|
171 | 171 | return -1; |
172 | 172 | } |
173 | 173 | } |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param int $multicurrency Return multicurrency_amount instead of amount |
179 | 179 | * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
180 | 180 | */ |
181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
181 | + function getSumCreditNotesUsed($multicurrency = 0) |
|
182 | 182 | { |
183 | 183 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
184 | 184 | |
185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
185 | + $discountstatic = new DiscountAbsolute($this->db); |
|
186 | + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
187 | 187 | if ($result >= 0) |
188 | 188 | { |
189 | 189 | return $result; |
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
193 | - $this->error=$discountstatic->error; |
|
193 | + $this->error = $discountstatic->error; |
|
194 | 194 | return -1; |
195 | 195 | } |
196 | 196 | } |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | */ |
203 | 203 | function getListIdAvoirFromInvoice() |
204 | 204 | { |
205 | - $idarray=array(); |
|
205 | + $idarray = array(); |
|
206 | 206 | |
207 | 207 | $sql = 'SELECT rowid'; |
208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
210 | - $sql.= ' AND type = 2'; |
|
211 | - $resql=$this->db->query($sql); |
|
208 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
210 | + $sql .= ' AND type = 2'; |
|
211 | + $resql = $this->db->query($sql); |
|
212 | 212 | if ($resql) |
213 | 213 | { |
214 | 214 | $num = $this->db->num_rows($resql); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | while ($i < $num) |
217 | 217 | { |
218 | 218 | $row = $this->db->fetch_row($resql); |
219 | - $idarray[]=$row[0]; |
|
219 | + $idarray[] = $row[0]; |
|
220 | 220 | $i++; |
221 | 221 | } |
222 | 222 | } |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | * @param string $option filtre sur statut ('', 'validated', ...) |
234 | 234 | * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
235 | 235 | */ |
236 | - function getIdReplacingInvoice($option='') |
|
236 | + function getIdReplacingInvoice($option = '') |
|
237 | 237 | { |
238 | 238 | $sql = 'SELECT rowid'; |
239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
241 | - $sql.= ' AND type < 2'; |
|
242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
239 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
241 | + $sql .= ' AND type < 2'; |
|
242 | + if ($option == 'validated') $sql .= ' AND fk_statut = 1'; |
|
243 | 243 | // PROTECTION BAD DATA |
244 | 244 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
245 | 245 | // et une autre non, on donne priorite a la validee. |
246 | 246 | // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
247 | 247 | // ont cree en meme temps une facture de remplacement pour la meme facture) |
248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
248 | + $sql .= ' ORDER BY fk_statut DESC'; |
|
249 | 249 | |
250 | - $resql=$this->db->query($sql); |
|
250 | + $resql = $this->db->query($sql); |
|
251 | 251 | if ($resql) |
252 | 252 | { |
253 | 253 | $obj = $this->db->fetch_object($resql); |
@@ -274,43 +274,43 @@ discard block |
||
274 | 274 | * @param string $filtertype 1 to filter on type of payment == 'PRE' |
275 | 275 | * @return array Array with list of payments |
276 | 276 | */ |
277 | - function getListOfPayments($filtertype='') |
|
277 | + function getListOfPayments($filtertype = '') |
|
278 | 278 | { |
279 | - $retarray=array(); |
|
279 | + $retarray = array(); |
|
280 | 280 | |
281 | - $table='paiement_facture'; |
|
282 | - $table2='paiement'; |
|
283 | - $field='fk_facture'; |
|
284 | - $field2='fk_paiement'; |
|
285 | - $sharedentity='facture'; |
|
281 | + $table = 'paiement_facture'; |
|
282 | + $table2 = 'paiement'; |
|
283 | + $field = 'fk_facture'; |
|
284 | + $field2 = 'fk_paiement'; |
|
285 | + $sharedentity = 'facture'; |
|
286 | 286 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
287 | 287 | { |
288 | - $table='paiementfourn_facturefourn'; |
|
289 | - $table2='paiementfourn'; |
|
290 | - $field='fk_facturefourn'; |
|
291 | - $field2='fk_paiementfourn'; |
|
292 | - $sharedentity='facture_fourn'; |
|
288 | + $table = 'paiementfourn_facturefourn'; |
|
289 | + $table2 = 'paiementfourn'; |
|
290 | + $field = 'fk_facturefourn'; |
|
291 | + $field2 = 'fk_paiementfourn'; |
|
292 | + $sharedentity = 'facture_fourn'; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
296 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | + $sql .= ' WHERE pf.'.$field.' = '.$this->id; |
|
298 | 298 | //$sql.= ' WHERE pf.'.$field.' = 1'; |
299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
299 | + $sql .= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | + $sql .= ' AND p.fk_paiement = t.id'; |
|
301 | + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; |
|
302 | + if ($filtertype) $sql .= " AND t.code='PRE'"; |
|
303 | 303 | |
304 | 304 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
305 | - $resql=$this->db->query($sql); |
|
305 | + $resql = $this->db->query($sql); |
|
306 | 306 | if ($resql) |
307 | 307 | { |
308 | 308 | $num = $this->db->num_rows($resql); |
309 | - $i=0; |
|
309 | + $i = 0; |
|
310 | 310 | while ($i < $num) |
311 | 311 | { |
312 | 312 | $obj = $this->db->fetch_object($resql); |
313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
313 | + $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
314 | 314 | $i++; |
315 | 315 | } |
316 | 316 | $this->db->free($resql); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | else |
320 | 320 | { |
321 | - $this->error=$this->db->lasterror(); |
|
321 | + $this->error = $this->db->lasterror(); |
|
322 | 322 | dol_print_error($this->db); |
323 | 323 | return array(); |
324 | 324 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return 1; |
353 | 353 | } |
354 | 354 | |
355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
355 | + if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
356 | 356 | |
357 | 357 | // If not a draft invoice and not temporary invoice |
358 | 358 | if ($tmppart !== 'PROV') |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | // Get last number of validated invoice |
364 | 364 | if ($this->element != 'invoice_supplier') |
365 | 365 | { |
366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | + $maxref = $this->getNextNumRef($this->thirdparty, 'last'); |
|
368 | 368 | |
369 | 369 | // If there is no invoice into the reset range and not already dispatched, we can delete |
370 | 370 | // If invoice to delete is last one and not already dispatched, we can delete |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
377 | 377 | { |
378 | 378 | $last = $this->is_last_in_cycle(); |
379 | - if (! $last) return -3; |
|
379 | + if (!$last) return -3; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
438 | + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
440 | 440 | return $langs->trans("Unknown"); |
441 | 441 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
448 | 448 | * @return string Label of status |
449 | 449 | */ |
450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
450 | + function getLibStatut($mode = 0, $alreadypaid = -1) |
|
451 | 451 | { |
452 | 452 | return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
453 | 453 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param int $type Type invoice |
464 | 464 | * @return string Label of status |
465 | 465 | */ |
466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
466 | + function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) |
|
467 | 467 | { |
468 | 468 | // phpcs:enable |
469 | 469 | global $langs; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | //print "$paye,$status,$mode,$alreadypaid,$type"; |
473 | 473 | if ($mode == 0) |
474 | 474 | { |
475 | - $prefix=''; |
|
476 | - if (! $paye) |
|
475 | + $prefix = ''; |
|
476 | + if (!$paye) |
|
477 | 477 | { |
478 | 478 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
479 | 479 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | } |
484 | 484 | else |
485 | 485 | { |
486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | 488 | else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
489 | 489 | } |
490 | 490 | } |
491 | 491 | elseif ($mode == 1) |
492 | 492 | { |
493 | - $prefix='Short'; |
|
494 | - if (! $paye) |
|
493 | + $prefix = 'Short'; |
|
494 | + if (!$paye) |
|
495 | 495 | { |
496 | 496 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
497 | 497 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
@@ -508,79 +508,79 @@ discard block |
||
508 | 508 | } |
509 | 509 | elseif ($mode == 2) |
510 | 510 | { |
511 | - $prefix='Short'; |
|
512 | - if (! $paye) |
|
511 | + $prefix = 'Short'; |
|
512 | + if (!$paye) |
|
513 | 513 | { |
514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | 519 | } |
520 | 520 | else |
521 | 521 | { |
522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | elseif ($mode == 3) |
528 | 528 | { |
529 | - $prefix='Short'; |
|
530 | - if (! $paye) |
|
529 | + $prefix = 'Short'; |
|
530 | + if (!$paye) |
|
531 | 531 | { |
532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
536 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
537 | 537 | } |
538 | 538 | else |
539 | 539 | { |
540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
542 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | elseif ($mode == 4) |
546 | 546 | { |
547 | - $prefix=''; |
|
548 | - if (! $paye) |
|
547 | + $prefix = ''; |
|
548 | + if (!$paye) |
|
549 | 549 | { |
550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | 555 | } |
556 | 556 | else |
557 | 557 | { |
558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('BillStatusPaid'); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | elseif ($mode == 5 || $mode == 6) |
564 | 564 | { |
565 | - $prefix=''; |
|
566 | - if ($mode == 5) $prefix='Short'; |
|
567 | - if (! $paye) |
|
565 | + $prefix = ''; |
|
566 | + if ($mode == 5) $prefix = 'Short'; |
|
567 | + if (!$paye) |
|
568 | 568 | { |
569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
572 | 572 | elseif ($alreadypaid <= 0) |
573 | 573 | { |
574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'), 'statut1'); |
|
575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
576 | 576 | } |
577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
578 | 578 | } |
579 | 579 | else |
580 | 580 | { |
581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -593,26 +593,26 @@ discard block |
||
593 | 593 | * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
594 | 594 | * @return date Date limite de reglement si ok, <0 si ko |
595 | 595 | */ |
596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
596 | + function calculate_date_lim_reglement($cond_reglement = 0) |
|
597 | 597 | { |
598 | 598 | // phpcs:enable |
599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
599 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; |
|
600 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; |
|
601 | 601 | |
602 | - $cdr_nbjour=0; |
|
603 | - $cdr_type=0; |
|
604 | - $cdr_decalage=0; |
|
602 | + $cdr_nbjour = 0; |
|
603 | + $cdr_type = 0; |
|
604 | + $cdr_decalage = 0; |
|
605 | 605 | |
606 | 606 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
607 | + $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | + if (is_numeric($cond_reglement)) $sqltemp .= " WHERE c.rowid=".$cond_reglement; |
|
609 | 609 | else { |
610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
610 | + $sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | + $sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
615 | - $resqltemp=$this->db->query($sqltemp); |
|
615 | + $resqltemp = $this->db->query($sqltemp); |
|
616 | 616 | if ($resqltemp) |
617 | 617 | { |
618 | 618 | if ($this->db->num_rows($resqltemp)) |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | else |
627 | 627 | { |
628 | - $this->error=$this->db->error(); |
|
628 | + $this->error = $this->db->error(); |
|
629 | 629 | return -1; |
630 | 630 | } |
631 | 631 | $this->db->free($resqltemp); |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | { |
645 | 645 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
646 | 646 | |
647 | - $mois=date('m', $datelim); |
|
648 | - $annee=date('Y', $datelim); |
|
647 | + $mois = date('m', $datelim); |
|
648 | + $annee = date('Y', $datelim); |
|
649 | 649 | if ($mois == 12) |
650 | 650 | { |
651 | 651 | $mois = 1; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $mois += 1; |
657 | 657 | } |
658 | 658 | // On se deplace au debut du mois suivant, et on retire un jour |
659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
659 | + $datelim = dol_mktime(12, 0, 0, $mois, 1, $annee); |
|
660 | 660 | $datelim -= (3600 * 24); |
661 | 661 | |
662 | 662 | $datelim += ($cdr_decalage * 3600 * 24); |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | { |
667 | 667 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
668 | 668 | |
669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes |
|
670 | 670 | $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
672 | 672 | |
673 | 673 | $diff = $date_piece - $date_lim_current; |
674 | 674 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | |
685 | 685 | |
686 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; |
|
686 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; |
|
687 | 687 | |
688 | 688 | /** |
689 | 689 | * Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...) |
@@ -132,10 +132,12 @@ discard block |
||
132 | 132 | { |
133 | 133 | $obj = $this->db->fetch_object($resql); |
134 | 134 | $this->db->free($resql); |
135 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
136 | - else return $obj->amount; |
|
137 | - } |
|
138 | - else |
|
135 | + if ($multicurrency) { |
|
136 | + return $obj->multicurrency_amount; |
|
137 | + } else { |
|
138 | + return $obj->amount; |
|
139 | + } |
|
140 | + } else |
|
139 | 141 | { |
140 | 142 | $this->error=$this->db->lasterror(); |
141 | 143 | return -1; |
@@ -164,8 +166,7 @@ discard block |
||
164 | 166 | if ($result >= 0) |
165 | 167 | { |
166 | 168 | return $result; |
167 | - } |
|
168 | - else |
|
169 | + } else |
|
169 | 170 | { |
170 | 171 | $this->error=$discountstatic->error; |
171 | 172 | return -1; |
@@ -187,8 +188,7 @@ discard block |
||
187 | 188 | if ($result >= 0) |
188 | 189 | { |
189 | 190 | return $result; |
190 | - } |
|
191 | - else |
|
191 | + } else |
|
192 | 192 | { |
193 | 193 | $this->error=$discountstatic->error; |
194 | 194 | return -1; |
@@ -219,8 +219,7 @@ discard block |
||
219 | 219 | $idarray[]=$row[0]; |
220 | 220 | $i++; |
221 | 221 | } |
222 | - } |
|
223 | - else |
|
222 | + } else |
|
224 | 223 | { |
225 | 224 | dol_print_error($this->db); |
226 | 225 | } |
@@ -239,7 +238,9 @@ discard block |
||
239 | 238 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
240 | 239 | $sql.= ' WHERE fk_facture_source = '.$this->id; |
241 | 240 | $sql.= ' AND type < 2'; |
242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
241 | + if ($option == 'validated') { |
|
242 | + $sql.= ' AND fk_statut = 1'; |
|
243 | + } |
|
243 | 244 | // PROTECTION BAD DATA |
244 | 245 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
245 | 246 | // et une autre non, on donne priorite a la validee. |
@@ -255,14 +256,12 @@ discard block |
||
255 | 256 | { |
256 | 257 | // Si il y en a |
257 | 258 | return $obj->rowid; |
258 | - } |
|
259 | - else |
|
259 | + } else |
|
260 | 260 | { |
261 | 261 | // Si aucune facture ne remplace |
262 | 262 | return 0; |
263 | 263 | } |
264 | - } |
|
265 | - else |
|
264 | + } else |
|
266 | 265 | { |
267 | 266 | return -1; |
268 | 267 | } |
@@ -299,7 +298,9 @@ discard block |
||
299 | 298 | $sql.= ' AND pf.'.$field2.' = p.rowid'; |
300 | 299 | $sql.= ' AND p.fk_paiement = t.id'; |
301 | 300 | $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
301 | + if ($filtertype) { |
|
302 | + $sql.=" AND t.code='PRE'"; |
|
303 | + } |
|
303 | 304 | |
304 | 305 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
305 | 306 | $resql=$this->db->query($sql); |
@@ -315,8 +316,7 @@ discard block |
||
315 | 316 | } |
316 | 317 | $this->db->free($resql); |
317 | 318 | return $retarray; |
318 | - } |
|
319 | - else |
|
319 | + } else |
|
320 | 320 | { |
321 | 321 | $this->error=$this->db->lasterror(); |
322 | 322 | dol_print_error($this->db); |
@@ -347,28 +347,39 @@ discard block |
||
347 | 347 | // We check if invoice is a temporary number (PROVxxxx) |
348 | 348 | $tmppart = substr($this->ref, 1, 4); |
349 | 349 | |
350 | - if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
350 | + if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') { |
|
351 | + // If draft invoice and ref not yet defined |
|
351 | 352 | { |
352 | 353 | return 1; |
353 | 354 | } |
355 | + } |
|
354 | 356 | |
355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
357 | + if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) { |
|
358 | + return 0; |
|
359 | + } |
|
356 | 360 | |
357 | 361 | // If not a draft invoice and not temporary invoice |
358 | 362 | if ($tmppart !== 'PROV') |
359 | 363 | { |
360 | 364 | $ventilExportCompta = $this->getVentilExportCompta(); |
361 | - if ($ventilExportCompta != 0) return -1; |
|
365 | + if ($ventilExportCompta != 0) { |
|
366 | + return -1; |
|
367 | + } |
|
362 | 368 | |
363 | 369 | // Get last number of validated invoice |
364 | 370 | if ($this->element != 'invoice_supplier') |
365 | 371 | { |
366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
372 | + if (empty($this->thirdparty)) { |
|
373 | + $this->fetch_thirdparty(); |
|
374 | + } |
|
375 | + // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | 376 | $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
368 | 377 | |
369 | 378 | // If there is no invoice into the reset range and not already dispatched, we can delete |
370 | 379 | // If invoice to delete is last one and not already dispatched, we can delete |
371 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
380 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) { |
|
381 | + return -2; |
|
382 | + } |
|
372 | 383 | |
373 | 384 | // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
374 | 385 | // ... |
@@ -376,13 +387,17 @@ discard block |
||
376 | 387 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
377 | 388 | { |
378 | 389 | $last = $this->is_last_in_cycle(); |
379 | - if (! $last) return -3; |
|
390 | + if (! $last) { |
|
391 | + return -3; |
|
392 | + } |
|
380 | 393 | } |
381 | 394 | } |
382 | 395 | } |
383 | 396 | |
384 | 397 | // Test if there is at least one payment. If yes, refuse to delete. |
385 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
398 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) { |
|
399 | + return -4; |
|
400 | + } |
|
386 | 401 | |
387 | 402 | return 2; |
388 | 403 | } |
@@ -397,7 +412,9 @@ discard block |
||
397 | 412 | $alreadydispatched = 0; |
398 | 413 | |
399 | 414 | $type = 'customer_invoice'; |
400 | - if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
415 | + if ($this->element == 'invoice_supplier') { |
|
416 | + $type = 'supplier_invoice'; |
|
417 | + } |
|
401 | 418 | |
402 | 419 | $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
403 | 420 | $resql = $this->db->query($sql); |
@@ -408,8 +425,7 @@ discard block |
||
408 | 425 | { |
409 | 426 | $alreadydispatched = $obj->nb; |
410 | 427 | } |
411 | - } |
|
412 | - else |
|
428 | + } else |
|
413 | 429 | { |
414 | 430 | $this->error = $this->db->lasterror(); |
415 | 431 | return -1; |
@@ -431,12 +447,21 @@ discard block |
||
431 | 447 | function getLibType() |
432 | 448 | { |
433 | 449 | global $langs; |
434 | - if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); |
|
435 | - elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
|
436 | - elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
|
437 | - elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
|
438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
439 | - elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
|
450 | + if ($this->type == CommonInvoice::TYPE_STANDARD) { |
|
451 | + return $langs->trans("InvoiceStandard"); |
|
452 | + } elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) { |
|
453 | + return $langs->trans("InvoiceReplacement"); |
|
454 | + } elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) { |
|
455 | + return $langs->trans("InvoiceAvoir"); |
|
456 | + } elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) { |
|
457 | + return $langs->trans("InvoiceDeposit"); |
|
458 | + } elseif ($this->type == CommonInvoice::TYPE_PROFORMA) { |
|
459 | + return $langs->trans("InvoiceProForma"); |
|
460 | + } |
|
461 | + // Not used. |
|
462 | + elseif ($this->type == CommonInvoice::TYPE_SITUATION) { |
|
463 | + return $langs->trans("InvoiceSituation"); |
|
464 | + } |
|
440 | 465 | return $langs->trans("Unknown"); |
441 | 466 | } |
442 | 467 | |
@@ -475,112 +500,167 @@ discard block |
||
475 | 500 | $prefix=''; |
476 | 501 | if (! $paye) |
477 | 502 | { |
478 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
479 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
480 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
481 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
482 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
483 | - } |
|
484 | - else |
|
503 | + if ($status == 0) { |
|
504 | + return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
505 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
506 | + return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
507 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
508 | + return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
509 | + } elseif ($alreadypaid <= 0) { |
|
510 | + return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
511 | + } else { |
|
512 | + return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
513 | + } |
|
514 | + } else |
|
485 | 515 | { |
486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
516 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
517 | + return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
518 | + } |
|
519 | + // credit note |
|
520 | + elseif ($type == self::TYPE_DEPOSIT) { |
|
521 | + return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
522 | + } |
|
523 | + // deposit invoice |
|
524 | + else { |
|
525 | + return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
526 | + } |
|
489 | 527 | } |
490 | - } |
|
491 | - elseif ($mode == 1) |
|
528 | + } elseif ($mode == 1) |
|
492 | 529 | { |
493 | 530 | $prefix='Short'; |
494 | 531 | if (! $paye) |
495 | 532 | { |
496 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
497 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
498 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
499 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
500 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
501 | - } |
|
502 | - else |
|
533 | + if ($status == 0) { |
|
534 | + return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
535 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
536 | + return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
537 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
538 | + return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
539 | + } elseif ($alreadypaid <= 0) { |
|
540 | + return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
541 | + } else { |
|
542 | + return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
543 | + } |
|
544 | + } else |
|
503 | 545 | { |
504 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
505 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
506 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
546 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
547 | + return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
548 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
549 | + return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
550 | + } else { |
|
551 | + return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
552 | + } |
|
507 | 553 | } |
508 | - } |
|
509 | - elseif ($mode == 2) |
|
554 | + } elseif ($mode == 2) |
|
510 | 555 | { |
511 | 556 | $prefix='Short'; |
512 | 557 | if (! $paye) |
513 | 558 | { |
514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | - } |
|
520 | - else |
|
559 | + if ($status == 0) { |
|
560 | + return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
561 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
562 | + return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
563 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
564 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
565 | + } elseif ($alreadypaid <= 0) { |
|
566 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
567 | + } else { |
|
568 | + return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
569 | + } |
|
570 | + } else |
|
521 | 571 | { |
522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
572 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
573 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
574 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
575 | + return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
576 | + } else { |
|
577 | + return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
578 | + } |
|
525 | 579 | } |
526 | - } |
|
527 | - elseif ($mode == 3) |
|
580 | + } elseif ($mode == 3) |
|
528 | 581 | { |
529 | 582 | $prefix='Short'; |
530 | 583 | if (! $paye) |
531 | 584 | { |
532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
537 | - } |
|
538 | - else |
|
585 | + if ($status == 0) { |
|
586 | + return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
587 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
588 | + return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
589 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
590 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
591 | + } elseif ($alreadypaid <= 0) { |
|
592 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
593 | + } else { |
|
594 | + return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
595 | + } |
|
596 | + } else |
|
539 | 597 | { |
540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
598 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
599 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
600 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
601 | + return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
602 | + } else { |
|
603 | + return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
604 | + } |
|
543 | 605 | } |
544 | - } |
|
545 | - elseif ($mode == 4) |
|
606 | + } elseif ($mode == 4) |
|
546 | 607 | { |
547 | 608 | $prefix=''; |
548 | 609 | if (! $paye) |
549 | 610 | { |
550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | - } |
|
556 | - else |
|
611 | + if ($status == 0) { |
|
612 | + return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
613 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
614 | + return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
615 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
616 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
617 | + } elseif ($alreadypaid <= 0) { |
|
618 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
619 | + } else { |
|
620 | + return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
621 | + } |
|
622 | + } else |
|
557 | 623 | { |
558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
624 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
625 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
626 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
627 | + return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
628 | + } else { |
|
629 | + return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
630 | + } |
|
561 | 631 | } |
562 | - } |
|
563 | - elseif ($mode == 5 || $mode == 6) |
|
632 | + } elseif ($mode == 5 || $mode == 6) |
|
564 | 633 | { |
565 | 634 | $prefix=''; |
566 | - if ($mode == 5) $prefix='Short'; |
|
635 | + if ($mode == 5) { |
|
636 | + $prefix='Short'; |
|
637 | + } |
|
567 | 638 | if (! $paye) |
568 | 639 | { |
569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
572 | - elseif ($alreadypaid <= 0) |
|
640 | + if ($status == 0) { |
|
641 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
642 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
643 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
644 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
645 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
646 | + } elseif ($alreadypaid <= 0) |
|
573 | 647 | { |
574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
648 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
649 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
650 | + } |
|
575 | 651 | return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
652 | + } else { |
|
653 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
576 | 654 | } |
577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
578 | - } |
|
579 | - else |
|
655 | + } else |
|
580 | 656 | { |
581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
657 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
658 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
659 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
660 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
661 | + } else { |
|
662 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
663 | + } |
|
584 | 664 | } |
585 | 665 | } |
586 | 666 | } |
@@ -596,8 +676,12 @@ discard block |
||
596 | 676 | function calculate_date_lim_reglement($cond_reglement=0) |
597 | 677 | { |
598 | 678 | // phpcs:enable |
599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
679 | + if (! $cond_reglement) { |
|
680 | + $cond_reglement=$this->cond_reglement_code; |
|
681 | + } |
|
682 | + if (! $cond_reglement) { |
|
683 | + $cond_reglement=$this->cond_reglement_id; |
|
684 | + } |
|
601 | 685 | |
602 | 686 | $cdr_nbjour=0; |
603 | 687 | $cdr_type=0; |
@@ -605,8 +689,9 @@ discard block |
||
605 | 689 | |
606 | 690 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
607 | 691 | $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
609 | - else { |
|
692 | + if (is_numeric($cond_reglement)) { |
|
693 | + $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
694 | + } else { |
|
610 | 695 | $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
611 | 696 | $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
612 | 697 | } |
@@ -622,8 +707,7 @@ discard block |
||
622 | 707 | $cdr_type = $obj->type_cdr; |
623 | 708 | $cdr_decalage = $obj->decalage; |
624 | 709 | } |
625 | - } |
|
626 | - else |
|
710 | + } else |
|
627 | 711 | { |
628 | 712 | $this->error=$this->db->error(); |
629 | 713 | return -1; |
@@ -650,8 +734,7 @@ discard block |
||
650 | 734 | { |
651 | 735 | $mois = 1; |
652 | 736 | $annee += 1; |
653 | - } |
|
654 | - else |
|
737 | + } else |
|
655 | 738 | { |
656 | 739 | $mois += 1; |
657 | 740 | } |
@@ -672,10 +755,14 @@ discard block |
||
672 | 755 | |
673 | 756 | $diff = $date_piece - $date_lim_current; |
674 | 757 | |
675 | - if ($diff < 0) $datelim = $date_lim_current; |
|
676 | - else $datelim = $date_lim_next; |
|
758 | + if ($diff < 0) { |
|
759 | + $datelim = $date_lim_current; |
|
760 | + } else { |
|
761 | + $datelim = $date_lim_next; |
|
762 | + } |
|
763 | + } else { |
|
764 | + return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
677 | 765 | } |
678 | - else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
679 | 766 | |
680 | 767 | return $datelim; |
681 | 768 | } |
@@ -21,347 +21,347 @@ |
||
21 | 21 | */ |
22 | 22 | class Comment extends CommonObject |
23 | 23 | { |
24 | - /** |
|
25 | - * @var string ID to identify managed object |
|
26 | - */ |
|
27 | - public $element='comment'; |
|
24 | + /** |
|
25 | + * @var string ID to identify managed object |
|
26 | + */ |
|
27 | + public $element='comment'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var string Name of table without prefix where object is stored |
|
31 | - */ |
|
32 | - public $table_element='comment'; |
|
29 | + /** |
|
30 | + * @var string Name of table without prefix where object is stored |
|
31 | + */ |
|
32 | + public $table_element='comment'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var int Field with ID of parent key if this field has a parent |
|
36 | - */ |
|
37 | - public $fk_element =''; |
|
34 | + /** |
|
35 | + * @var int Field with ID of parent key if this field has a parent |
|
36 | + */ |
|
37 | + public $fk_element =''; |
|
38 | 38 | |
39 | - public $element_type; |
|
39 | + public $element_type; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var string description |
|
43 | - */ |
|
44 | - public $description; |
|
41 | + /** |
|
42 | + * @var string description |
|
43 | + */ |
|
44 | + public $description; |
|
45 | 45 | |
46 | - public $tms; |
|
46 | + public $tms; |
|
47 | 47 | |
48 | - public $datec; |
|
48 | + public $datec; |
|
49 | 49 | |
50 | - /** |
|
50 | + /** |
|
51 | 51 | * @var int ID |
52 | 52 | */ |
53 | - public $fk_user_author; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var int Entity |
|
57 | - */ |
|
58 | - public $entity; |
|
59 | - |
|
60 | - public $import_key; |
|
61 | - |
|
62 | - public $comments = array(); |
|
63 | - |
|
64 | - public $oldcopy; |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Constructor |
|
69 | - * |
|
70 | - * @param DoliDB $db Database handler |
|
71 | - */ |
|
72 | - function __construct($db) |
|
73 | - { |
|
74 | - $this->db = $db; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Create into database |
|
80 | - * |
|
81 | - * @param User $user User that create |
|
82 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
83 | - * @return int <0 if KO, Id of created object if OK |
|
84 | - */ |
|
85 | - function create($user, $notrigger=0) |
|
86 | - { |
|
87 | - global $conf, $langs; |
|
88 | - |
|
89 | - $error=0; |
|
90 | - |
|
91 | - // Insert request |
|
92 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
|
93 | - $sql.= "description"; |
|
94 | - $sql.= ", datec"; |
|
95 | - $sql.= ", fk_element"; |
|
96 | - $sql.= ", element_type"; |
|
97 | - $sql.= ", fk_user_author"; |
|
98 | - $sql.= ", entity"; |
|
99 | - $sql.= ", import_key"; |
|
100 | - $sql.= ") VALUES ("; |
|
101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
108 | - $sql.= ")"; |
|
109 | - |
|
110 | - //var_dump($this->db); |
|
111 | - //echo $sql; |
|
112 | - |
|
113 | - $this->db->begin(); |
|
114 | - |
|
115 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
116 | - $resql=$this->db->query($sql); |
|
117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
118 | - |
|
119 | - if (! $error) |
|
120 | - { |
|
121 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
|
122 | - |
|
123 | - if (! $notrigger) |
|
124 | - { |
|
125 | - // Call trigger |
|
126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
127 | - if ($result < 0) { $error++; } |
|
128 | - // End call triggers |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - // Commit or rollback |
|
133 | - if ($error) |
|
134 | - { |
|
135 | - foreach($this->errors as $errmsg) |
|
136 | - { |
|
137 | - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
139 | - } |
|
140 | - $this->db->rollback(); |
|
141 | - return -1*$error; |
|
142 | - } |
|
143 | - else |
|
144 | - { |
|
145 | - $this->db->commit(); |
|
146 | - return $this->id; |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * Load object in memory from database |
|
153 | - * |
|
154 | - * @param int $id Id object |
|
155 | - * @param int $ref ref object |
|
156 | - * @return int <0 if KO, 0 if not found, >0 if OK |
|
157 | - */ |
|
158 | - function fetch($id, $ref='') |
|
159 | - { |
|
160 | - global $langs; |
|
161 | - |
|
162 | - $sql = "SELECT"; |
|
163 | - $sql.= " c.rowid,"; |
|
164 | - $sql.= " c.description,"; |
|
165 | - $sql.= " c.datec,"; |
|
166 | - $sql.= " c.tms,"; |
|
167 | - $sql.= " c.fk_element,"; |
|
168 | - $sql.= " c.element_type,"; |
|
169 | - $sql.= " c.fk_user_author,"; |
|
170 | - $sql.= " c.entity,"; |
|
171 | - $sql.= " c.import_key"; |
|
172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | - $sql.= " WHERE c.rowid = ".$id; |
|
174 | - |
|
175 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
176 | - $resql=$this->db->query($sql); |
|
177 | - if ($resql) |
|
178 | - { |
|
179 | - $num_rows = $this->db->num_rows($resql); |
|
180 | - |
|
181 | - if ($num_rows) |
|
182 | - { |
|
183 | - $obj = $this->db->fetch_object($resql); |
|
184 | - |
|
185 | - $this->id = $obj->rowid; |
|
186 | - $this->description = $obj->description; |
|
187 | - $this->element_type = $obj->element_type; |
|
188 | - $this->datec = $this->db->jdate($obj->datec); |
|
189 | - $this->tms = $obj->tms; |
|
190 | - $this->fk_user_author = $obj->fk_user_author; |
|
191 | - $this->fk_element = $obj->fk_element; |
|
192 | - $this->entity = $obj->entity; |
|
193 | - $this->import_key = $obj->import_key; |
|
194 | - } |
|
195 | - |
|
196 | - $this->db->free($resql); |
|
197 | - |
|
198 | - if ($num_rows) return 1; |
|
199 | - else return 0; |
|
200 | - } |
|
201 | - else |
|
202 | - { |
|
203 | - $this->error="Error ".$this->db->lasterror(); |
|
204 | - return -1; |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * Update database |
|
211 | - * |
|
212 | - * @param User $user User that modify |
|
213 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
214 | - * @return int <=0 if KO, >0 if OK |
|
215 | - */ |
|
216 | - function update(User $user, $notrigger=0) |
|
217 | - { |
|
218 | - global $conf, $langs; |
|
219 | - $error=0; |
|
220 | - |
|
221 | - // Clean parameters |
|
222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
225 | - |
|
226 | - |
|
227 | - // Update request |
|
228 | - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
|
229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
236 | - $sql.= " WHERE rowid=".$this->id; |
|
237 | - |
|
238 | - $this->db->begin(); |
|
239 | - |
|
240 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
241 | - $resql = $this->db->query($sql); |
|
242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
243 | - |
|
244 | - if (! $error) |
|
245 | - { |
|
246 | - if (! $notrigger) |
|
247 | - { |
|
248 | - // Call trigger |
|
249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
250 | - if ($result < 0) { $error++; } |
|
251 | - // End call triggers |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - // Commit or rollback |
|
256 | - if ($error) |
|
257 | - { |
|
258 | - foreach($this->errors as $errmsg) |
|
259 | - { |
|
260 | - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
262 | - } |
|
263 | - $this->db->rollback(); |
|
264 | - return -1*$error; |
|
265 | - } |
|
266 | - else |
|
267 | - { |
|
268 | - $this->db->commit(); |
|
269 | - return 1; |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * Delete task from database |
|
276 | - * |
|
277 | - * @param User $user User that delete |
|
278 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
279 | - * @return int <0 if KO, >0 if OK |
|
280 | - */ |
|
281 | - function delete($user, $notrigger=0) |
|
282 | - { |
|
283 | - global $conf, $langs; |
|
284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
285 | - |
|
286 | - $error=0; |
|
287 | - |
|
288 | - $this->db->begin(); |
|
289 | - |
|
290 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
|
291 | - $sql.= " WHERE rowid=".$this->id; |
|
292 | - |
|
293 | - $resql = $this->db->query($sql); |
|
294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
295 | - |
|
296 | - if (! $error) |
|
297 | - { |
|
298 | - if (! $notrigger) |
|
299 | - { |
|
300 | - // Call trigger |
|
301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
302 | - if ($result < 0) { $error++; } |
|
303 | - // End call triggers |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - // Commit or rollback |
|
308 | - if ($error) |
|
309 | - { |
|
310 | - foreach($this->errors as $errmsg) |
|
311 | - { |
|
312 | - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
314 | - } |
|
315 | - $this->db->rollback(); |
|
316 | - return -1*$error; |
|
317 | - }else{ |
|
318 | - $this->db->commit(); |
|
319 | - return 1; |
|
320 | - } |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Load comments linked with current task |
|
326 | - * |
|
327 | - * @param string $element_type Element type |
|
328 | - * @param int $fk_element Id of element |
|
329 | - * @return array Comment array |
|
330 | - */ |
|
331 | - public function fetchAllFor($element_type, $fk_element) |
|
332 | - { |
|
333 | - global $db,$conf; |
|
334 | - $this->comments = array(); |
|
335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
336 | - $sql = "SELECT"; |
|
337 | - $sql.= " c.rowid"; |
|
338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
342 | - $sql.= " ORDER BY c.tms DESC"; |
|
343 | - |
|
344 | - dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
|
345 | - $resql=$db->query($sql); |
|
346 | - if ($resql) |
|
347 | - { |
|
348 | - $num_rows = $db->num_rows($resql); |
|
349 | - if ($num_rows > 0) |
|
350 | - { |
|
351 | - while($obj = $db->fetch_object($resql)) |
|
352 | - { |
|
353 | - $comment = new self($db); |
|
354 | - $comment->fetch($obj->rowid); |
|
355 | - $this->comments[] = $comment; |
|
356 | - } |
|
357 | - } |
|
358 | - $db->free($resql); |
|
359 | - } else { |
|
360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
361 | - return -1; |
|
362 | - } |
|
363 | - } |
|
364 | - |
|
365 | - return count($this->comments); |
|
366 | - } |
|
53 | + public $fk_user_author; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var int Entity |
|
57 | + */ |
|
58 | + public $entity; |
|
59 | + |
|
60 | + public $import_key; |
|
61 | + |
|
62 | + public $comments = array(); |
|
63 | + |
|
64 | + public $oldcopy; |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Constructor |
|
69 | + * |
|
70 | + * @param DoliDB $db Database handler |
|
71 | + */ |
|
72 | + function __construct($db) |
|
73 | + { |
|
74 | + $this->db = $db; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Create into database |
|
80 | + * |
|
81 | + * @param User $user User that create |
|
82 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
83 | + * @return int <0 if KO, Id of created object if OK |
|
84 | + */ |
|
85 | + function create($user, $notrigger=0) |
|
86 | + { |
|
87 | + global $conf, $langs; |
|
88 | + |
|
89 | + $error=0; |
|
90 | + |
|
91 | + // Insert request |
|
92 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
|
93 | + $sql.= "description"; |
|
94 | + $sql.= ", datec"; |
|
95 | + $sql.= ", fk_element"; |
|
96 | + $sql.= ", element_type"; |
|
97 | + $sql.= ", fk_user_author"; |
|
98 | + $sql.= ", entity"; |
|
99 | + $sql.= ", import_key"; |
|
100 | + $sql.= ") VALUES ("; |
|
101 | + $sql.= "'".$this->db->escape($this->description)."'"; |
|
102 | + $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
103 | + $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
104 | + $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | + $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
106 | + $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
107 | + $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
108 | + $sql.= ")"; |
|
109 | + |
|
110 | + //var_dump($this->db); |
|
111 | + //echo $sql; |
|
112 | + |
|
113 | + $this->db->begin(); |
|
114 | + |
|
115 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
116 | + $resql=$this->db->query($sql); |
|
117 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
118 | + |
|
119 | + if (! $error) |
|
120 | + { |
|
121 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
|
122 | + |
|
123 | + if (! $notrigger) |
|
124 | + { |
|
125 | + // Call trigger |
|
126 | + $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
127 | + if ($result < 0) { $error++; } |
|
128 | + // End call triggers |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + // Commit or rollback |
|
133 | + if ($error) |
|
134 | + { |
|
135 | + foreach($this->errors as $errmsg) |
|
136 | + { |
|
137 | + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
138 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
139 | + } |
|
140 | + $this->db->rollback(); |
|
141 | + return -1*$error; |
|
142 | + } |
|
143 | + else |
|
144 | + { |
|
145 | + $this->db->commit(); |
|
146 | + return $this->id; |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Load object in memory from database |
|
153 | + * |
|
154 | + * @param int $id Id object |
|
155 | + * @param int $ref ref object |
|
156 | + * @return int <0 if KO, 0 if not found, >0 if OK |
|
157 | + */ |
|
158 | + function fetch($id, $ref='') |
|
159 | + { |
|
160 | + global $langs; |
|
161 | + |
|
162 | + $sql = "SELECT"; |
|
163 | + $sql.= " c.rowid,"; |
|
164 | + $sql.= " c.description,"; |
|
165 | + $sql.= " c.datec,"; |
|
166 | + $sql.= " c.tms,"; |
|
167 | + $sql.= " c.fk_element,"; |
|
168 | + $sql.= " c.element_type,"; |
|
169 | + $sql.= " c.fk_user_author,"; |
|
170 | + $sql.= " c.entity,"; |
|
171 | + $sql.= " c.import_key"; |
|
172 | + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | + $sql.= " WHERE c.rowid = ".$id; |
|
174 | + |
|
175 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
176 | + $resql=$this->db->query($sql); |
|
177 | + if ($resql) |
|
178 | + { |
|
179 | + $num_rows = $this->db->num_rows($resql); |
|
180 | + |
|
181 | + if ($num_rows) |
|
182 | + { |
|
183 | + $obj = $this->db->fetch_object($resql); |
|
184 | + |
|
185 | + $this->id = $obj->rowid; |
|
186 | + $this->description = $obj->description; |
|
187 | + $this->element_type = $obj->element_type; |
|
188 | + $this->datec = $this->db->jdate($obj->datec); |
|
189 | + $this->tms = $obj->tms; |
|
190 | + $this->fk_user_author = $obj->fk_user_author; |
|
191 | + $this->fk_element = $obj->fk_element; |
|
192 | + $this->entity = $obj->entity; |
|
193 | + $this->import_key = $obj->import_key; |
|
194 | + } |
|
195 | + |
|
196 | + $this->db->free($resql); |
|
197 | + |
|
198 | + if ($num_rows) return 1; |
|
199 | + else return 0; |
|
200 | + } |
|
201 | + else |
|
202 | + { |
|
203 | + $this->error="Error ".$this->db->lasterror(); |
|
204 | + return -1; |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * Update database |
|
211 | + * |
|
212 | + * @param User $user User that modify |
|
213 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
214 | + * @return int <=0 if KO, >0 if OK |
|
215 | + */ |
|
216 | + function update(User $user, $notrigger=0) |
|
217 | + { |
|
218 | + global $conf, $langs; |
|
219 | + $error=0; |
|
220 | + |
|
221 | + // Clean parameters |
|
222 | + if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | + if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | + if (isset($this->description)) $this->description=trim($this->description); |
|
225 | + |
|
226 | + |
|
227 | + // Update request |
|
228 | + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
|
229 | + $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
230 | + $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
231 | + $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
232 | + $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | + $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
234 | + $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
235 | + $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
236 | + $sql.= " WHERE rowid=".$this->id; |
|
237 | + |
|
238 | + $this->db->begin(); |
|
239 | + |
|
240 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
241 | + $resql = $this->db->query($sql); |
|
242 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
243 | + |
|
244 | + if (! $error) |
|
245 | + { |
|
246 | + if (! $notrigger) |
|
247 | + { |
|
248 | + // Call trigger |
|
249 | + $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
250 | + if ($result < 0) { $error++; } |
|
251 | + // End call triggers |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + // Commit or rollback |
|
256 | + if ($error) |
|
257 | + { |
|
258 | + foreach($this->errors as $errmsg) |
|
259 | + { |
|
260 | + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
261 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
262 | + } |
|
263 | + $this->db->rollback(); |
|
264 | + return -1*$error; |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
268 | + $this->db->commit(); |
|
269 | + return 1; |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * Delete task from database |
|
276 | + * |
|
277 | + * @param User $user User that delete |
|
278 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
279 | + * @return int <0 if KO, >0 if OK |
|
280 | + */ |
|
281 | + function delete($user, $notrigger=0) |
|
282 | + { |
|
283 | + global $conf, $langs; |
|
284 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
285 | + |
|
286 | + $error=0; |
|
287 | + |
|
288 | + $this->db->begin(); |
|
289 | + |
|
290 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
|
291 | + $sql.= " WHERE rowid=".$this->id; |
|
292 | + |
|
293 | + $resql = $this->db->query($sql); |
|
294 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
295 | + |
|
296 | + if (! $error) |
|
297 | + { |
|
298 | + if (! $notrigger) |
|
299 | + { |
|
300 | + // Call trigger |
|
301 | + $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
302 | + if ($result < 0) { $error++; } |
|
303 | + // End call triggers |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + // Commit or rollback |
|
308 | + if ($error) |
|
309 | + { |
|
310 | + foreach($this->errors as $errmsg) |
|
311 | + { |
|
312 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
313 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
314 | + } |
|
315 | + $this->db->rollback(); |
|
316 | + return -1*$error; |
|
317 | + }else{ |
|
318 | + $this->db->commit(); |
|
319 | + return 1; |
|
320 | + } |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Load comments linked with current task |
|
326 | + * |
|
327 | + * @param string $element_type Element type |
|
328 | + * @param int $fk_element Id of element |
|
329 | + * @return array Comment array |
|
330 | + */ |
|
331 | + public function fetchAllFor($element_type, $fk_element) |
|
332 | + { |
|
333 | + global $db,$conf; |
|
334 | + $this->comments = array(); |
|
335 | + if(!empty($element_type) && !empty($fk_element)) { |
|
336 | + $sql = "SELECT"; |
|
337 | + $sql.= " c.rowid"; |
|
338 | + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | + $sql.= " WHERE c.fk_element = ".$fk_element; |
|
340 | + $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | + $sql.= " AND c.entity = ".$conf->entity; |
|
342 | + $sql.= " ORDER BY c.tms DESC"; |
|
343 | + |
|
344 | + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
|
345 | + $resql=$db->query($sql); |
|
346 | + if ($resql) |
|
347 | + { |
|
348 | + $num_rows = $db->num_rows($resql); |
|
349 | + if ($num_rows > 0) |
|
350 | + { |
|
351 | + while($obj = $db->fetch_object($resql)) |
|
352 | + { |
|
353 | + $comment = new self($db); |
|
354 | + $comment->fetch($obj->rowid); |
|
355 | + $this->comments[] = $comment; |
|
356 | + } |
|
357 | + } |
|
358 | + $db->free($resql); |
|
359 | + } else { |
|
360 | + $this->errors[]="Error ".$this->db->lasterror(); |
|
361 | + return -1; |
|
362 | + } |
|
363 | + } |
|
364 | + |
|
365 | + return count($this->comments); |
|
366 | + } |
|
367 | 367 | } |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var string ID to identify managed object |
26 | 26 | */ |
27 | - public $element='comment'; |
|
27 | + public $element = 'comment'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var string Name of table without prefix where object is stored |
31 | 31 | */ |
32 | - public $table_element='comment'; |
|
32 | + public $table_element = 'comment'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @var int Field with ID of parent key if this field has a parent |
36 | 36 | */ |
37 | - public $fk_element =''; |
|
37 | + public $fk_element = ''; |
|
38 | 38 | |
39 | 39 | public $element_type; |
40 | 40 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
83 | 83 | * @return int <0 if KO, Id of created object if OK |
84 | 84 | */ |
85 | - function create($user, $notrigger=0) |
|
85 | + function create($user, $notrigger = 0) |
|
86 | 86 | { |
87 | 87 | global $conf, $langs; |
88 | 88 | |
89 | - $error=0; |
|
89 | + $error = 0; |
|
90 | 90 | |
91 | 91 | // Insert request |
92 | 92 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
93 | - $sql.= "description"; |
|
94 | - $sql.= ", datec"; |
|
95 | - $sql.= ", fk_element"; |
|
96 | - $sql.= ", element_type"; |
|
97 | - $sql.= ", fk_user_author"; |
|
98 | - $sql.= ", entity"; |
|
99 | - $sql.= ", import_key"; |
|
100 | - $sql.= ") VALUES ("; |
|
101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
108 | - $sql.= ")"; |
|
93 | + $sql .= "description"; |
|
94 | + $sql .= ", datec"; |
|
95 | + $sql .= ", fk_element"; |
|
96 | + $sql .= ", element_type"; |
|
97 | + $sql .= ", fk_user_author"; |
|
98 | + $sql .= ", entity"; |
|
99 | + $sql .= ", import_key"; |
|
100 | + $sql .= ") VALUES ("; |
|
101 | + $sql .= "'".$this->db->escape($this->description)."'"; |
|
102 | + $sql .= ", ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); |
|
103 | + $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; |
|
104 | + $sql .= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | + $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; |
|
106 | + $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); |
|
107 | + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
108 | + $sql .= ")"; |
|
109 | 109 | |
110 | 110 | //var_dump($this->db); |
111 | 111 | //echo $sql; |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | $this->db->begin(); |
114 | 114 | |
115 | 115 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
116 | - $resql=$this->db->query($sql); |
|
117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
116 | + $resql = $this->db->query($sql); |
|
117 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
118 | 118 | |
119 | - if (! $error) |
|
119 | + if (!$error) |
|
120 | 120 | { |
121 | 121 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
122 | 122 | |
123 | - if (! $notrigger) |
|
123 | + if (!$notrigger) |
|
124 | 124 | { |
125 | 125 | // Call trigger |
126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
126 | + $result = $this->call_trigger('TASK_COMMENT_CREATE', $user); |
|
127 | 127 | if ($result < 0) { $error++; } |
128 | 128 | // End call triggers |
129 | 129 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | // Commit or rollback |
133 | 133 | if ($error) |
134 | 134 | { |
135 | - foreach($this->errors as $errmsg) |
|
135 | + foreach ($this->errors as $errmsg) |
|
136 | 136 | { |
137 | 137 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
138 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
139 | 139 | } |
140 | 140 | $this->db->rollback(); |
141 | - return -1*$error; |
|
141 | + return -1 * $error; |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | * @param int $ref ref object |
156 | 156 | * @return int <0 if KO, 0 if not found, >0 if OK |
157 | 157 | */ |
158 | - function fetch($id, $ref='') |
|
158 | + function fetch($id, $ref = '') |
|
159 | 159 | { |
160 | 160 | global $langs; |
161 | 161 | |
162 | 162 | $sql = "SELECT"; |
163 | - $sql.= " c.rowid,"; |
|
164 | - $sql.= " c.description,"; |
|
165 | - $sql.= " c.datec,"; |
|
166 | - $sql.= " c.tms,"; |
|
167 | - $sql.= " c.fk_element,"; |
|
168 | - $sql.= " c.element_type,"; |
|
169 | - $sql.= " c.fk_user_author,"; |
|
170 | - $sql.= " c.entity,"; |
|
171 | - $sql.= " c.import_key"; |
|
172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | - $sql.= " WHERE c.rowid = ".$id; |
|
163 | + $sql .= " c.rowid,"; |
|
164 | + $sql .= " c.description,"; |
|
165 | + $sql .= " c.datec,"; |
|
166 | + $sql .= " c.tms,"; |
|
167 | + $sql .= " c.fk_element,"; |
|
168 | + $sql .= " c.element_type,"; |
|
169 | + $sql .= " c.fk_user_author,"; |
|
170 | + $sql .= " c.entity,"; |
|
171 | + $sql .= " c.import_key"; |
|
172 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | + $sql .= " WHERE c.rowid = ".$id; |
|
174 | 174 | |
175 | 175 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
176 | - $resql=$this->db->query($sql); |
|
176 | + $resql = $this->db->query($sql); |
|
177 | 177 | if ($resql) |
178 | 178 | { |
179 | 179 | $num_rows = $this->db->num_rows($resql); |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | { |
183 | 183 | $obj = $this->db->fetch_object($resql); |
184 | 184 | |
185 | - $this->id = $obj->rowid; |
|
186 | - $this->description = $obj->description; |
|
187 | - $this->element_type = $obj->element_type; |
|
188 | - $this->datec = $this->db->jdate($obj->datec); |
|
189 | - $this->tms = $obj->tms; |
|
190 | - $this->fk_user_author = $obj->fk_user_author; |
|
185 | + $this->id = $obj->rowid; |
|
186 | + $this->description = $obj->description; |
|
187 | + $this->element_type = $obj->element_type; |
|
188 | + $this->datec = $this->db->jdate($obj->datec); |
|
189 | + $this->tms = $obj->tms; |
|
190 | + $this->fk_user_author = $obj->fk_user_author; |
|
191 | 191 | $this->fk_element = $obj->fk_element; |
192 | - $this->entity = $obj->entity; |
|
192 | + $this->entity = $obj->entity; |
|
193 | 193 | $this->import_key = $obj->import_key; |
194 | 194 | } |
195 | 195 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
203 | - $this->error="Error ".$this->db->lasterror(); |
|
203 | + $this->error = "Error ".$this->db->lasterror(); |
|
204 | 204 | return -1; |
205 | 205 | } |
206 | 206 | } |
@@ -213,40 +213,40 @@ discard block |
||
213 | 213 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
214 | 214 | * @return int <=0 if KO, >0 if OK |
215 | 215 | */ |
216 | - function update(User $user, $notrigger=0) |
|
216 | + function update(User $user, $notrigger = 0) |
|
217 | 217 | { |
218 | 218 | global $conf, $langs; |
219 | - $error=0; |
|
219 | + $error = 0; |
|
220 | 220 | |
221 | 221 | // Clean parameters |
222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
222 | + if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element); |
|
223 | + if (isset($this->fk_user_author)) $this->fk_user_author = (int) trim($this->fk_user_author); |
|
224 | + if (isset($this->description)) $this->description = trim($this->description); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | // Update request |
228 | 228 | $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
236 | - $sql.= " WHERE rowid=".$this->id; |
|
229 | + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; |
|
230 | + $sql .= " datec=".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null').","; |
|
231 | + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; |
|
232 | + $sql .= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
|
234 | + $sql .= " entity=".(!empty($this->entity) ? $this->entity : '1').","; |
|
235 | + $sql .= " import_key=".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
236 | + $sql .= " WHERE rowid=".$this->id; |
|
237 | 237 | |
238 | 238 | $this->db->begin(); |
239 | 239 | |
240 | 240 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
241 | 241 | $resql = $this->db->query($sql); |
242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
242 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
243 | 243 | |
244 | - if (! $error) |
|
244 | + if (!$error) |
|
245 | 245 | { |
246 | - if (! $notrigger) |
|
246 | + if (!$notrigger) |
|
247 | 247 | { |
248 | 248 | // Call trigger |
249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
249 | + $result = $this->call_trigger('TASK_COMMENT_MODIFY', $user); |
|
250 | 250 | if ($result < 0) { $error++; } |
251 | 251 | // End call triggers |
252 | 252 | } |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | // Commit or rollback |
256 | 256 | if ($error) |
257 | 257 | { |
258 | - foreach($this->errors as $errmsg) |
|
258 | + foreach ($this->errors as $errmsg) |
|
259 | 259 | { |
260 | 260 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
261 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
262 | 262 | } |
263 | 263 | $this->db->rollback(); |
264 | - return -1*$error; |
|
264 | + return -1 * $error; |
|
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
@@ -278,27 +278,27 @@ discard block |
||
278 | 278 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
279 | 279 | * @return int <0 if KO, >0 if OK |
280 | 280 | */ |
281 | - function delete($user, $notrigger=0) |
|
281 | + function delete($user, $notrigger = 0) |
|
282 | 282 | { |
283 | 283 | global $conf, $langs; |
284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
284 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
285 | 285 | |
286 | - $error=0; |
|
286 | + $error = 0; |
|
287 | 287 | |
288 | 288 | $this->db->begin(); |
289 | 289 | |
290 | 290 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
291 | - $sql.= " WHERE rowid=".$this->id; |
|
291 | + $sql .= " WHERE rowid=".$this->id; |
|
292 | 292 | |
293 | 293 | $resql = $this->db->query($sql); |
294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
294 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
295 | 295 | |
296 | - if (! $error) |
|
296 | + if (!$error) |
|
297 | 297 | { |
298 | - if (! $notrigger) |
|
298 | + if (!$notrigger) |
|
299 | 299 | { |
300 | 300 | // Call trigger |
301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
301 | + $result = $this->call_trigger('TASK_COMMENT_DELETE', $user); |
|
302 | 302 | if ($result < 0) { $error++; } |
303 | 303 | // End call triggers |
304 | 304 | } |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | // Commit or rollback |
308 | 308 | if ($error) |
309 | 309 | { |
310 | - foreach($this->errors as $errmsg) |
|
310 | + foreach ($this->errors as $errmsg) |
|
311 | 311 | { |
312 | 312 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
313 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
314 | 314 | } |
315 | 315 | $this->db->rollback(); |
316 | - return -1*$error; |
|
317 | - }else{ |
|
316 | + return -1 * $error; |
|
317 | + } else { |
|
318 | 318 | $this->db->commit(); |
319 | 319 | return 1; |
320 | 320 | } |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function fetchAllFor($element_type, $fk_element) |
332 | 332 | { |
333 | - global $db,$conf; |
|
333 | + global $db, $conf; |
|
334 | 334 | $this->comments = array(); |
335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
335 | + if (!empty($element_type) && !empty($fk_element)) { |
|
336 | 336 | $sql = "SELECT"; |
337 | - $sql.= " c.rowid"; |
|
338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
342 | - $sql.= " ORDER BY c.tms DESC"; |
|
337 | + $sql .= " c.rowid"; |
|
338 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | + $sql .= " WHERE c.fk_element = ".$fk_element; |
|
340 | + $sql .= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | + $sql .= " AND c.entity = ".$conf->entity; |
|
342 | + $sql .= " ORDER BY c.tms DESC"; |
|
343 | 343 | |
344 | 344 | dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
345 | - $resql=$db->query($sql); |
|
345 | + $resql = $db->query($sql); |
|
346 | 346 | if ($resql) |
347 | 347 | { |
348 | 348 | $num_rows = $db->num_rows($resql); |
349 | 349 | if ($num_rows > 0) |
350 | 350 | { |
351 | - while($obj = $db->fetch_object($resql)) |
|
351 | + while ($obj = $db->fetch_object($resql)) |
|
352 | 352 | { |
353 | 353 | $comment = new self($db); |
354 | 354 | $comment->fetch($obj->rowid); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | $db->free($resql); |
359 | 359 | } else { |
360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
360 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
361 | 361 | return -1; |
362 | 362 | } |
363 | 363 | } |
@@ -139,8 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | $this->db->rollback(); |
141 | 141 | return -1*$error; |
142 | - } |
|
143 | - else |
|
142 | + } else |
|
144 | 143 | { |
145 | 144 | $this->db->commit(); |
146 | 145 | return $this->id; |
@@ -195,10 +194,12 @@ discard block |
||
195 | 194 | |
196 | 195 | $this->db->free($resql); |
197 | 196 | |
198 | - if ($num_rows) return 1; |
|
199 | - else return 0; |
|
200 | - } |
|
201 | - else |
|
197 | + if ($num_rows) { |
|
198 | + return 1; |
|
199 | + } else { |
|
200 | + return 0; |
|
201 | + } |
|
202 | + } else |
|
202 | 203 | { |
203 | 204 | $this->error="Error ".$this->db->lasterror(); |
204 | 205 | return -1; |
@@ -219,9 +220,15 @@ discard block |
||
219 | 220 | $error=0; |
220 | 221 | |
221 | 222 | // Clean parameters |
222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
223 | + if (isset($this->fk_element)) { |
|
224 | + $this->fk_project=(int) trim($this->fk_element); |
|
225 | + } |
|
226 | + if (isset($this->fk_user_author)) { |
|
227 | + $this->fk_user_author=(int) trim($this->fk_user_author); |
|
228 | + } |
|
229 | + if (isset($this->description)) { |
|
230 | + $this->description=trim($this->description); |
|
231 | + } |
|
225 | 232 | |
226 | 233 | |
227 | 234 | // Update request |
@@ -262,8 +269,7 @@ discard block |
||
262 | 269 | } |
263 | 270 | $this->db->rollback(); |
264 | 271 | return -1*$error; |
265 | - } |
|
266 | - else |
|
272 | + } else |
|
267 | 273 | { |
268 | 274 | $this->db->commit(); |
269 | 275 | return 1; |
@@ -314,7 +320,7 @@ discard block |
||
314 | 320 | } |
315 | 321 | $this->db->rollback(); |
316 | 322 | return -1*$error; |
317 | - }else{ |
|
323 | + } else{ |
|
318 | 324 | $this->db->commit(); |
319 | 325 | return 1; |
320 | 326 | } |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | public $db; |
36 | 36 | |
37 | 37 | /** |
38 | - * @var string Error code (or message) |
|
39 | - */ |
|
40 | - public $error=''; |
|
38 | + * @var string Error code (or message) |
|
39 | + */ |
|
40 | + public $error=''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
44 | - * Constructor |
|
45 | - * |
|
46 | - * @param DoliDB $db Database handler |
|
44 | + * Constructor |
|
45 | + * |
|
46 | + * @param DoliDB $db Database handler |
|
47 | 47 | */ |
48 | 48 | function __construct($db) |
49 | 49 | { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | '50' => $langs->trans("ActionRunningShort"), |
76 | 76 | '100' => $langs->trans("ActionDoneShort") |
77 | 77 | ); |
78 | - // +ActionUncomplete |
|
78 | + // +ActionUncomplete |
|
79 | 79 | |
80 | 80 | if (! empty($conf->use_javascript_ajax)) |
81 | 81 | { |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | } |
128 | 128 | if (! empty($conf->use_javascript_ajax) || $onlyselect) |
129 | 129 | { |
130 | - //var_dump($selected); |
|
131 | - if ($selected == 'done') $selected='100'; |
|
130 | + //var_dump($selected); |
|
131 | + if ($selected == 'done') $selected='100'; |
|
132 | 132 | print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
133 | 133 | if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
134 | 134 | foreach($listofstatus as $key => $val) |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
137 | 137 | if ($key == '50' && $onlyselect == 2) |
138 | 138 | { |
139 | - print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>'; |
|
139 | + print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>'; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | print '</select>'; |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | |
145 | 145 | if (empty($onlyselect)) |
146 | 146 | { |
147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
148 | - print '<span class="hideonsmartphone hideifna">%</span>'; |
|
147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
148 | + print '<span class="hideonsmartphone hideifna">%</span>'; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | else |
152 | - { |
|
152 | + { |
|
153 | 153 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
154 | 154 | } |
155 | 155 | } |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | $sortorder='DESC,DESC'; |
180 | 180 | |
181 | 181 | $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
182 | + if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
183 | 183 | |
184 | 184 | $num = count($listofactions); |
185 | 185 | if ($num || $forceshowtitle) |
186 | 186 | { |
187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
187 | + if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | + elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | + elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | + elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | + elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
194 | 194 | elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
195 | 195 | elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
196 | 196 | elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
@@ -203,111 +203,111 @@ discard block |
||
203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
204 | 204 | |
205 | 205 | $newcardbutton=''; |
206 | - if (! empty($conf->agenda->enabled)) |
|
207 | - { |
|
208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | - $newcardbutton.= '</a>'; |
|
211 | - } |
|
212 | - |
|
213 | - print '<!-- formactions->showactions -->'."\n"; |
|
214 | - print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
|
215 | - |
|
216 | - $page=0; $param=''; |
|
217 | - |
|
218 | - $total = 0; |
|
219 | - |
|
220 | - print '<div class="div-table-responsive-no-min">'; |
|
221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
222 | - print '<tr class="liste_titre">'; |
|
223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
226 | - print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
229 | - print '</tr>'; |
|
230 | - print "\n"; |
|
231 | - |
|
232 | - $userstatic = new User($this->db); |
|
233 | - |
|
234 | - if (count($listofactions)) |
|
235 | - { |
|
236 | - $cursorevent = 0; |
|
237 | - foreach($listofactions as $action) |
|
238 | - { |
|
239 | - if ($max && $cursorevent >= $max) break; |
|
240 | - |
|
241 | - $ref=$action->getNomUrl(1,-1); |
|
242 | - $label=$action->getNomUrl(0,38); |
|
243 | - |
|
244 | - print '<tr class="oddeven">'; |
|
245 | - // Ref |
|
246 | - print '<td>'.$ref.'</td>'; |
|
247 | - // Onwer |
|
248 | - print '<td>'; |
|
249 | - if (! empty($action->userownerid)) |
|
250 | - { |
|
251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
252 | - print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
|
253 | - } |
|
254 | - print '</td>'; |
|
255 | - // Type |
|
256 | - print '<td>'; |
|
257 | - $imgpicto=''; |
|
258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
259 | - { |
|
260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
261 | - else { |
|
262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
268 | - } |
|
269 | - } |
|
270 | - print $imgpicto; |
|
271 | - print $action->type_short ? $action->type_short : $action->type; |
|
272 | - print '</td>'; |
|
273 | - // Label |
|
274 | - print '<td>'.$label.'</td>'; |
|
275 | - // Date |
|
276 | - print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
|
277 | - if ($action->datef) |
|
278 | - { |
|
279 | - $tmpa=dol_getdate($action->datep); |
|
280 | - $tmpb=dol_getdate($action->datef); |
|
281 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
|
282 | - { |
|
283 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
284 | - } |
|
285 | - else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
286 | - } |
|
287 | - print '</td>'; |
|
288 | - print '<td align="right">'; |
|
289 | - if (! empty($action->author->id)) |
|
290 | - { |
|
291 | - print $action->getLibStatut(3); |
|
292 | - } |
|
293 | - print '</td>'; |
|
294 | - print '</tr>'; |
|
295 | - |
|
296 | - $cursorevent++; |
|
297 | - } |
|
298 | - } |
|
299 | - else |
|
300 | - { |
|
301 | - print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
|
302 | - } |
|
303 | - |
|
304 | - if ($max && $num > $max) |
|
305 | - { |
|
306 | - print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>'; |
|
307 | - } |
|
308 | - |
|
309 | - print '</table>'; |
|
310 | - print '</div>'; |
|
206 | + if (! empty($conf->agenda->enabled)) |
|
207 | + { |
|
208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | + $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | + $newcardbutton.= '</a>'; |
|
211 | + } |
|
212 | + |
|
213 | + print '<!-- formactions->showactions -->'."\n"; |
|
214 | + print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
|
215 | + |
|
216 | + $page=0; $param=''; |
|
217 | + |
|
218 | + $total = 0; |
|
219 | + |
|
220 | + print '<div class="div-table-responsive-no-min">'; |
|
221 | + print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
222 | + print '<tr class="liste_titre">'; |
|
223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
226 | + print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
229 | + print '</tr>'; |
|
230 | + print "\n"; |
|
231 | + |
|
232 | + $userstatic = new User($this->db); |
|
233 | + |
|
234 | + if (count($listofactions)) |
|
235 | + { |
|
236 | + $cursorevent = 0; |
|
237 | + foreach($listofactions as $action) |
|
238 | + { |
|
239 | + if ($max && $cursorevent >= $max) break; |
|
240 | + |
|
241 | + $ref=$action->getNomUrl(1,-1); |
|
242 | + $label=$action->getNomUrl(0,38); |
|
243 | + |
|
244 | + print '<tr class="oddeven">'; |
|
245 | + // Ref |
|
246 | + print '<td>'.$ref.'</td>'; |
|
247 | + // Onwer |
|
248 | + print '<td>'; |
|
249 | + if (! empty($action->userownerid)) |
|
250 | + { |
|
251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
252 | + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
|
253 | + } |
|
254 | + print '</td>'; |
|
255 | + // Type |
|
256 | + print '<td>'; |
|
257 | + $imgpicto=''; |
|
258 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
259 | + { |
|
260 | + if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
261 | + else { |
|
262 | + if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | + elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | + elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | + elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | + elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | + elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
268 | + } |
|
269 | + } |
|
270 | + print $imgpicto; |
|
271 | + print $action->type_short ? $action->type_short : $action->type; |
|
272 | + print '</td>'; |
|
273 | + // Label |
|
274 | + print '<td>'.$label.'</td>'; |
|
275 | + // Date |
|
276 | + print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
|
277 | + if ($action->datef) |
|
278 | + { |
|
279 | + $tmpa=dol_getdate($action->datep); |
|
280 | + $tmpb=dol_getdate($action->datef); |
|
281 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
|
282 | + { |
|
283 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
284 | + } |
|
285 | + else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
286 | + } |
|
287 | + print '</td>'; |
|
288 | + print '<td align="right">'; |
|
289 | + if (! empty($action->author->id)) |
|
290 | + { |
|
291 | + print $action->getLibStatut(3); |
|
292 | + } |
|
293 | + print '</td>'; |
|
294 | + print '</tr>'; |
|
295 | + |
|
296 | + $cursorevent++; |
|
297 | + } |
|
298 | + } |
|
299 | + else |
|
300 | + { |
|
301 | + print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
|
302 | + } |
|
303 | + |
|
304 | + if ($max && $num > $max) |
|
305 | + { |
|
306 | + print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>'; |
|
307 | + } |
|
308 | + |
|
309 | + print '</table>'; |
|
310 | + print '</div>'; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $num; |
@@ -338,27 +338,27 @@ discard block |
||
338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
339 | 339 | $caction=new CActionComm($this->db); |
340 | 340 | |
341 | - // Suggest a list with manual events or all auto events |
|
342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
344 | - //asort($arraylist); |
|
341 | + // Suggest a list with manual events or all auto events |
|
342 | + $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | + array_unshift($arraylist,' '); // Add empty line at start |
|
344 | + //asort($arraylist); |
|
345 | 345 | |
346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
346 | + if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | + if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
348 | 348 | |
349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
349 | + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
350 | 350 | |
351 | - $out=''; |
|
351 | + $out=''; |
|
352 | 352 | |
353 | - if (! empty($multiselect)) |
|
354 | - { |
|
355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
357 | - } |
|
358 | - else |
|
359 | - { |
|
360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
361 | - } |
|
353 | + if (! empty($multiselect)) |
|
354 | + { |
|
355 | + if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
356 | + $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
357 | + } |
|
358 | + else |
|
359 | + { |
|
360 | + $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
361 | + } |
|
362 | 362 | |
363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
364 | 364 | { |
@@ -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 | /** |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * @param string $morecss More css on select field |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function form_select_status_action($formname, $selected, $canedit=1, $htmlname='complete', $showempty=0, $onlyselect=0, $morecss='maxwidth100') |
|
67 | + function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') |
|
68 | 68 | { |
69 | 69 | // phpcs:enable |
70 | - global $langs,$conf; |
|
70 | + global $langs, $conf; |
|
71 | 71 | |
72 | 72 | $listofstatus = array( |
73 | 73 | '-1' => $langs->trans("ActionNotApplicable"), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ); |
78 | 78 | // +ActionUncomplete |
79 | 79 | |
80 | - if (! empty($conf->use_javascript_ajax)) |
|
80 | + if (!empty($conf->use_javascript_ajax)) |
|
81 | 81 | { |
82 | 82 | print "\n"; |
83 | 83 | print "<script type=\"text/javascript\"> |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function select_status() { |
99 | 99 | var defaultvalue = $('#select' + htmlname).val(); |
100 | 100 | var percentage = $('input[name=percentage]'); |
101 | - var selected = '".(isset($selected)?$selected:'')."'; |
|
101 | + var selected = '".(isset($selected) ? $selected : '')."'; |
|
102 | 102 | var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); |
103 | 103 | |
104 | 104 | percentage.val(value); |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | } |
126 | 126 | </script>\n"; |
127 | 127 | } |
128 | - if (! empty($conf->use_javascript_ajax) || $onlyselect) |
|
128 | + if (!empty($conf->use_javascript_ajax) || $onlyselect) |
|
129 | 129 | { |
130 | 130 | //var_dump($selected); |
131 | - if ($selected == 'done') $selected='100'; |
|
132 | - print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
|
133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
134 | - foreach($listofstatus as $key => $val) |
|
131 | + if ($selected == 'done') $selected = '100'; |
|
132 | + print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; |
|
133 | + if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>'; |
|
134 | + foreach ($listofstatus as $key => $val) |
|
135 | 135 | { |
136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
137 | 137 | if ($key == '50' && $onlyselect == 2) |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | print '</select>'; |
143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
143 | + if ($selected == 0 || $selected == 100) $canedit = 0; |
|
144 | 144 | |
145 | 145 | if (empty($onlyselect)) |
146 | 146 | { |
147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>'; |
|
148 | 148 | print '<span class="hideonsmartphone hideifna">%</span>'; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
153 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
|
153 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%'; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -168,64 +168,64 @@ discard block |
||
168 | 168 | * @param string $morehtmlright More html text on right of title line |
169 | 169 | * @return int <0 if KO, >=0 if OK |
170 | 170 | */ |
171 | - function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='', $morehtmlright='') |
|
171 | + function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') |
|
172 | 172 | { |
173 | - global $langs,$conf,$user; |
|
173 | + global $langs, $conf, $user; |
|
174 | 174 | global $bc; |
175 | 175 | |
176 | 176 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
177 | 177 | |
178 | - $sortfield='a.datep,a.id'; |
|
179 | - $sortorder='DESC,DESC'; |
|
178 | + $sortfield = 'a.datep,a.id'; |
|
179 | + $sortorder = 'DESC,DESC'; |
|
180 | 180 | |
181 | - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
|
182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
181 | + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); |
|
182 | + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); |
|
183 | 183 | |
184 | 184 | $num = count($listofactions); |
185 | 185 | if ($num || $forceshowtitle) |
186 | 186 | { |
187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
199 | - |
|
200 | - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
|
187 | + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); |
|
188 | + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); |
|
189 | + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); |
|
190 | + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); |
|
191 | + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); |
|
192 | + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); |
|
193 | + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); |
|
194 | + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); |
|
195 | + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
196 | + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
197 | + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
198 | + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
|
199 | + |
|
200 | + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); |
|
201 | 201 | |
202 | 202 | $projectid = $object->fk_project; |
203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
204 | 204 | |
205 | - $newcardbutton=''; |
|
206 | - if (! empty($conf->agenda->enabled)) |
|
205 | + $newcardbutton = ''; |
|
206 | + if (!empty($conf->agenda->enabled)) |
|
207 | 207 | { |
208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | - $newcardbutton.= '</a>'; |
|
208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | + $newcardbutton .= '</a>'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | print '<!-- formactions->showactions -->'."\n"; |
214 | 214 | print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
215 | 215 | |
216 | - $page=0; $param=''; |
|
216 | + $page = 0; $param = ''; |
|
217 | 217 | |
218 | 218 | $total = 0; |
219 | 219 | |
220 | 220 | print '<div class="div-table-responsive-no-min">'; |
221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
221 | + print '<table class="noborder'.($morecss ? ' '.$morecss : '').'" width="100%">'; |
|
222 | 222 | print '<tr class="liste_titre">'; |
223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
226 | 226 | print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
229 | 229 | print '</tr>'; |
230 | 230 | print "\n"; |
231 | 231 | |
@@ -234,37 +234,37 @@ discard block |
||
234 | 234 | if (count($listofactions)) |
235 | 235 | { |
236 | 236 | $cursorevent = 0; |
237 | - foreach($listofactions as $action) |
|
237 | + foreach ($listofactions as $action) |
|
238 | 238 | { |
239 | 239 | if ($max && $cursorevent >= $max) break; |
240 | 240 | |
241 | - $ref=$action->getNomUrl(1,-1); |
|
242 | - $label=$action->getNomUrl(0,38); |
|
241 | + $ref = $action->getNomUrl(1, -1); |
|
242 | + $label = $action->getNomUrl(0, 38); |
|
243 | 243 | |
244 | 244 | print '<tr class="oddeven">'; |
245 | 245 | // Ref |
246 | 246 | print '<td>'.$ref.'</td>'; |
247 | 247 | // Onwer |
248 | 248 | print '<td>'; |
249 | - if (! empty($action->userownerid)) |
|
249 | + if (!empty($action->userownerid)) |
|
250 | 250 | { |
251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
252 | 252 | print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
253 | 253 | } |
254 | 254 | print '</td>'; |
255 | 255 | // Type |
256 | 256 | print '<td>'; |
257 | - $imgpicto=''; |
|
258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
257 | + $imgpicto = ''; |
|
258 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
259 | 259 | { |
260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
260 | + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); |
|
261 | 261 | else { |
262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
262 | + if ($action->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | + elseif ($action->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | + elseif ($action->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | + elseif ($action->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | + elseif ($action->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | + elseif (!preg_match('/_AUTO/', $action->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | print $imgpicto; |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
277 | 277 | if ($action->datef) |
278 | 278 | { |
279 | - $tmpa=dol_getdate($action->datep); |
|
280 | - $tmpb=dol_getdate($action->datef); |
|
279 | + $tmpa = dol_getdate($action->datep); |
|
280 | + $tmpb = dol_getdate($action->datef); |
|
281 | 281 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
282 | 282 | { |
283 | 283 | if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | print '</td>'; |
288 | 288 | print '<td align="right">'; |
289 | - if (! empty($action->author->id)) |
|
289 | + if (!empty($action->author->id)) |
|
290 | 290 | { |
291 | 291 | print $action->getLibStatut(3); |
292 | 292 | } |
@@ -327,42 +327,42 @@ discard block |
||
327 | 327 | * @param int $nooutput 1=No output |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - function select_type_actions($selected='', $htmlname='actioncode', $excludetype='', $onlyautoornot=0, $hideinfohelp=0, $multiselect=0, $nooutput=0) |
|
330 | + function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) |
|
331 | 331 | { |
332 | 332 | // phpcs:enable |
333 | - global $langs,$user,$form,$conf; |
|
333 | + global $langs, $user, $form, $conf; |
|
334 | 334 | |
335 | - if (! is_object($form)) $form=new Form($this->db); |
|
335 | + if (!is_object($form)) $form = new Form($this->db); |
|
336 | 336 | |
337 | 337 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
339 | - $caction=new CActionComm($this->db); |
|
339 | + $caction = new CActionComm($this->db); |
|
340 | 340 | |
341 | 341 | // Suggest a list with manual events or all auto events |
342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
342 | + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | + array_unshift($arraylist, ' '); // Add empty line at start |
|
344 | 344 | //asort($arraylist); |
345 | 345 | |
346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
346 | + if ($selected == 'manual') $selected = 'AC_OTH'; |
|
347 | + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; |
|
348 | 348 | |
349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
349 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
350 | 350 | |
351 | - $out=''; |
|
351 | + $out = ''; |
|
352 | 352 | |
353 | - if (! empty($multiselect)) |
|
353 | + if (!empty($multiselect)) |
|
354 | 354 | { |
355 | 355 | if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
356 | + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
357 | 357 | } |
358 | 358 | else |
359 | 359 | { |
360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
360 | + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
364 | 364 | { |
365 | - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
|
365 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | if ($nooutput) return $out; |
@@ -128,9 +128,13 @@ discard block |
||
128 | 128 | if (! empty($conf->use_javascript_ajax) || $onlyselect) |
129 | 129 | { |
130 | 130 | //var_dump($selected); |
131 | - if ($selected == 'done') $selected='100'; |
|
131 | + if ($selected == 'done') { |
|
132 | + $selected='100'; |
|
133 | + } |
|
132 | 134 | print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
135 | + if ($showempty) { |
|
136 | + print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
137 | + } |
|
134 | 138 | foreach($listofstatus as $key => $val) |
135 | 139 | { |
136 | 140 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
@@ -140,15 +144,16 @@ discard block |
||
140 | 144 | } |
141 | 145 | } |
142 | 146 | print '</select>'; |
143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
147 | + if ($selected == 0 || $selected == 100) { |
|
148 | + $canedit=0; |
|
149 | + } |
|
144 | 150 | |
145 | 151 | if (empty($onlyselect)) |
146 | 152 | { |
147 | 153 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
148 | 154 | print '<span class="hideonsmartphone hideifna">%</span>'; |
149 | 155 | } |
150 | - } |
|
151 | - else |
|
156 | + } else |
|
152 | 157 | { |
153 | 158 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
154 | 159 | } |
@@ -179,28 +184,45 @@ discard block |
||
179 | 184 | $sortorder='DESC,DESC'; |
180 | 185 | |
181 | 186 | $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
187 | + if (! is_array($listofactions)) { |
|
188 | + dol_print_error($this->db,'FailedToGetActions'); |
|
189 | + } |
|
183 | 190 | |
184 | 191 | $num = count($listofactions); |
185 | 192 | if ($num || $forceshowtitle) |
186 | 193 | { |
187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
194 | + if ($typeelement == 'invoice') { |
|
195 | + $title=$langs->trans('ActionsOnBill'); |
|
196 | + } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { |
|
197 | + $title=$langs->trans('ActionsOnBill'); |
|
198 | + } elseif ($typeelement == 'propal') { |
|
199 | + $title=$langs->trans('ActionsOnPropal'); |
|
200 | + } elseif ($typeelement == 'supplier_proposal') { |
|
201 | + $title=$langs->trans('ActionsOnSupplierProposal'); |
|
202 | + } elseif ($typeelement == 'order') { |
|
203 | + $title=$langs->trans('ActionsOnOrder'); |
|
204 | + } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { |
|
205 | + $title=$langs->trans('ActionsOnOrder'); |
|
206 | + } elseif ($typeelement == 'shipping') { |
|
207 | + $title=$langs->trans('ActionsOnShipping'); |
|
208 | + } elseif ($typeelement == 'fichinter') { |
|
209 | + $title=$langs->trans('ActionsOnFicheInter'); |
|
210 | + } elseif ($typeelement == 'project') { |
|
211 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
212 | + } elseif ($typeelement == 'task') { |
|
213 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
214 | + } elseif ($typeelement == 'member') { |
|
215 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
216 | + } else { |
|
217 | + $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
218 | + } |
|
199 | 219 | |
200 | 220 | $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
201 | 221 | |
202 | 222 | $projectid = $object->fk_project; |
203 | - if ($typeelement == 'project') $projectid = $object->id; |
|
223 | + if ($typeelement == 'project') { |
|
224 | + $projectid = $object->id; |
|
225 | + } |
|
204 | 226 | |
205 | 227 | $newcardbutton=''; |
206 | 228 | if (! empty($conf->agenda->enabled)) |
@@ -236,7 +258,9 @@ discard block |
||
236 | 258 | $cursorevent = 0; |
237 | 259 | foreach($listofactions as $action) |
238 | 260 | { |
239 | - if ($max && $cursorevent >= $max) break; |
|
261 | + if ($max && $cursorevent >= $max) { |
|
262 | + break; |
|
263 | + } |
|
240 | 264 | |
241 | 265 | $ref=$action->getNomUrl(1,-1); |
242 | 266 | $label=$action->getNomUrl(0,38); |
@@ -257,14 +281,22 @@ discard block |
||
257 | 281 | $imgpicto=''; |
258 | 282 | if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
259 | 283 | { |
260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
261 | - else { |
|
262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
284 | + if ($action->type_picto) { |
|
285 | + $imgpicto=img_picto('', $action->type_picto); |
|
286 | + } else { |
|
287 | + if ($action->type_code == 'AC_RDV') { |
|
288 | + $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
289 | + } elseif ($action->type_code == 'AC_TEL') { |
|
290 | + $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
291 | + } elseif ($action->type_code == 'AC_FAX') { |
|
292 | + $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
293 | + } elseif ($action->type_code == 'AC_EMAIL') { |
|
294 | + $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
295 | + } elseif ($action->type_code == 'AC_INT') { |
|
296 | + $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
297 | + } elseif (! preg_match('/_AUTO/', $action->type_code)) { |
|
298 | + $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
299 | + } |
|
268 | 300 | } |
269 | 301 | } |
270 | 302 | print $imgpicto; |
@@ -280,9 +312,12 @@ discard block |
||
280 | 312 | $tmpb=dol_getdate($action->datef); |
281 | 313 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
282 | 314 | { |
283 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
315 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { |
|
316 | + print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
317 | + } |
|
318 | + } else { |
|
319 | + print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
284 | 320 | } |
285 | - else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
286 | 321 | } |
287 | 322 | print '</td>'; |
288 | 323 | print '<td align="right">'; |
@@ -295,8 +330,7 @@ discard block |
||
295 | 330 | |
296 | 331 | $cursorevent++; |
297 | 332 | } |
298 | - } |
|
299 | - else |
|
333 | + } else |
|
300 | 334 | { |
301 | 335 | print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
302 | 336 | } |
@@ -332,7 +366,9 @@ discard block |
||
332 | 366 | // phpcs:enable |
333 | 367 | global $langs,$user,$form,$conf; |
334 | 368 | |
335 | - if (! is_object($form)) $form=new Form($this->db); |
|
369 | + if (! is_object($form)) { |
|
370 | + $form=new Form($this->db); |
|
371 | + } |
|
336 | 372 | |
337 | 373 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
338 | 374 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
@@ -343,19 +379,26 @@ discard block |
||
343 | 379 | array_unshift($arraylist,' '); // Add empty line at start |
344 | 380 | //asort($arraylist); |
345 | 381 | |
346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
382 | + if ($selected == 'manual') { |
|
383 | + $selected='AC_OTH'; |
|
384 | + } |
|
385 | + if ($selected == 'auto') { |
|
386 | + $selected='AC_OTH_AUTO'; |
|
387 | + } |
|
348 | 388 | |
349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
389 | + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) { |
|
390 | + unset($arraylist['AC_OTH_AUTO']); |
|
391 | + } |
|
350 | 392 | |
351 | 393 | $out=''; |
352 | 394 | |
353 | 395 | if (! empty($multiselect)) |
354 | 396 | { |
355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
397 | + if (!is_array($selected) && !empty($selected)) { |
|
398 | + $selected = explode(',', $selected); |
|
399 | + } |
|
356 | 400 | $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
357 | - } |
|
358 | - else |
|
401 | + } else |
|
359 | 402 | { |
360 | 403 | $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
361 | 404 | } |
@@ -365,8 +408,11 @@ discard block |
||
365 | 408 | $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
366 | 409 | } |
367 | 410 | |
368 | - if ($nooutput) return $out; |
|
369 | - else print $out; |
|
411 | + if ($nooutput) { |
|
412 | + return $out; |
|
413 | + } else { |
|
414 | + print $out; |
|
415 | + } |
|
370 | 416 | return ''; |
371 | 417 | } |
372 | 418 | } |
@@ -28,75 +28,75 @@ |
||
28 | 28 | */ |
29 | 29 | class FormCron extends Form |
30 | 30 | { |
31 | - /** |
|
31 | + /** |
|
32 | 32 | * @var DoliDB Database handler. |
33 | 33 | */ |
34 | 34 | public $db; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string Error code (or message) |
|
38 | - */ |
|
39 | - public $error=''; |
|
36 | + /** |
|
37 | + * @var string Error code (or message) |
|
38 | + */ |
|
39 | + public $error=''; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
44 | - * @param DoliDB $db Database handler |
|
45 | - */ |
|
46 | - function __construct($db) |
|
47 | - { |
|
48 | - $this->db = $db; |
|
49 | - } |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | + * @param DoliDB $db Database handler |
|
45 | + */ |
|
46 | + function __construct($db) |
|
47 | + { |
|
48 | + $this->db = $db; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | 52 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
53 | - /** |
|
54 | - * Display On Off selector |
|
55 | - * |
|
56 | - * @param string $htmlname Html control name |
|
57 | - * @param integer $selected selected value |
|
58 | - * @param integer $readonly Select is read only or not |
|
59 | - * @return string HTML select field |
|
60 | - */ |
|
61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
62 | - { |
|
53 | + /** |
|
54 | + * Display On Off selector |
|
55 | + * |
|
56 | + * @param string $htmlname Html control name |
|
57 | + * @param integer $selected selected value |
|
58 | + * @param integer $readonly Select is read only or not |
|
59 | + * @return string HTML select field |
|
60 | + */ |
|
61 | + function select_typejob($htmlname,$selected=0,$readonly=0) |
|
62 | + { |
|
63 | 63 | // phpcs:enable |
64 | - global $langs; |
|
64 | + global $langs; |
|
65 | 65 | |
66 | - $langs->load('cron@cron'); |
|
67 | - if (!empty($readonly)) { |
|
68 | - if ($selected=='command') { |
|
69 | - $out= $langs->trans('CronType_command'); |
|
70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | - $out.='</SELECT>'; |
|
73 | - } elseif ($selected=='method') { |
|
74 | - $out= $langs->trans('CronType_method'); |
|
75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | - $out.='</SELECT>'; |
|
78 | - } |
|
79 | - }else { |
|
66 | + $langs->load('cron@cron'); |
|
67 | + if (!empty($readonly)) { |
|
68 | + if ($selected=='command') { |
|
69 | + $out= $langs->trans('CronType_command'); |
|
70 | + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | + $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | + $out.='</SELECT>'; |
|
73 | + } elseif ($selected=='method') { |
|
74 | + $out= $langs->trans('CronType_method'); |
|
75 | + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | + $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | + $out.='</SELECT>'; |
|
78 | + } |
|
79 | + }else { |
|
80 | 80 | |
81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
81 | + $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
82 | 82 | |
83 | - if ($selected=='command') { |
|
84 | - $selected_attr=' selected '; |
|
85 | - } else { |
|
86 | - $selected_attr=''; |
|
87 | - } |
|
88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
83 | + if ($selected=='command') { |
|
84 | + $selected_attr=' selected '; |
|
85 | + } else { |
|
86 | + $selected_attr=''; |
|
87 | + } |
|
88 | + $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
89 | 89 | |
90 | - if ($selected=='method') { |
|
91 | - $selected_attr=' selected '; |
|
92 | - } else { |
|
93 | - $selected_attr=''; |
|
94 | - } |
|
95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
90 | + if ($selected=='method') { |
|
91 | + $selected_attr=' selected '; |
|
92 | + } else { |
|
93 | + $selected_attr=''; |
|
94 | + } |
|
95 | + $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
96 | 96 | |
97 | - $out.='</SELECT>'; |
|
98 | - } |
|
97 | + $out.='</SELECT>'; |
|
98 | + } |
|
99 | 99 | |
100 | - return $out; |
|
101 | - } |
|
100 | + return $out; |
|
101 | + } |
|
102 | 102 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var string Error code (or message) |
38 | 38 | */ |
39 | - public $error=''; |
|
39 | + public $error = ''; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Constructor |
@@ -58,43 +58,43 @@ discard block |
||
58 | 58 | * @param integer $readonly Select is read only or not |
59 | 59 | * @return string HTML select field |
60 | 60 | */ |
61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
61 | + function select_typejob($htmlname, $selected = 0, $readonly = 0) |
|
62 | 62 | { |
63 | 63 | // phpcs:enable |
64 | 64 | global $langs; |
65 | 65 | |
66 | 66 | $langs->load('cron@cron'); |
67 | 67 | if (!empty($readonly)) { |
68 | - if ($selected=='command') { |
|
69 | - $out= $langs->trans('CronType_command'); |
|
70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | - $out.='</SELECT>'; |
|
73 | - } elseif ($selected=='method') { |
|
74 | - $out= $langs->trans('CronType_method'); |
|
75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | - $out.='</SELECT>'; |
|
68 | + if ($selected == 'command') { |
|
69 | + $out = $langs->trans('CronType_command'); |
|
70 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | + $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | + $out .= '</SELECT>'; |
|
73 | + } elseif ($selected == 'method') { |
|
74 | + $out = $langs->trans('CronType_method'); |
|
75 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | + $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | + $out .= '</SELECT>'; |
|
78 | 78 | } |
79 | - }else { |
|
79 | + } else { |
|
80 | 80 | |
81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
81 | + $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
82 | 82 | |
83 | - if ($selected=='command') { |
|
84 | - $selected_attr=' selected '; |
|
83 | + if ($selected == 'command') { |
|
84 | + $selected_attr = ' selected '; |
|
85 | 85 | } else { |
86 | - $selected_attr=''; |
|
86 | + $selected_attr = ''; |
|
87 | 87 | } |
88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
88 | + $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
89 | 89 | |
90 | - if ($selected=='method') { |
|
91 | - $selected_attr=' selected '; |
|
90 | + if ($selected == 'method') { |
|
91 | + $selected_attr = ' selected '; |
|
92 | 92 | } else { |
93 | - $selected_attr=''; |
|
93 | + $selected_attr = ''; |
|
94 | 94 | } |
95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
95 | + $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
96 | 96 | |
97 | - $out.='</SELECT>'; |
|
97 | + $out .= '</SELECT>'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return $out; |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
77 | 77 | $out.='</SELECT>'; |
78 | 78 | } |
79 | - }else { |
|
79 | + } else { |
|
80 | 80 | |
81 | 81 | $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
82 | 82 |
@@ -27,33 +27,33 @@ |
||
27 | 27 | */ |
28 | 28 | class FormMailing extends Form |
29 | 29 | { |
30 | - /** |
|
31 | - * @var string[] Error codes (or messages) |
|
32 | - */ |
|
33 | - public $errors = array(); |
|
34 | - |
|
35 | - /** |
|
36 | - * Output a select with destinaries status |
|
37 | - * |
|
38 | - * @param string $selectedid The selected id |
|
39 | - * @param string $htmlname Name of controm |
|
40 | - * @param integer $show_empty Show empty option |
|
41 | - * @return string HTML select |
|
42 | - */ |
|
30 | + /** |
|
31 | + * @var string[] Error codes (or messages) |
|
32 | + */ |
|
33 | + public $errors = array(); |
|
34 | + |
|
35 | + /** |
|
36 | + * Output a select with destinaries status |
|
37 | + * |
|
38 | + * @param string $selectedid The selected id |
|
39 | + * @param string $htmlname Name of controm |
|
40 | + * @param integer $show_empty Show empty option |
|
41 | + * @return string HTML select |
|
42 | + */ |
|
43 | 43 | public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
44 | 44 | { |
45 | 45 | |
46 | - global $langs; |
|
47 | - $langs->load("mails"); |
|
46 | + global $langs; |
|
47 | + $langs->load("mails"); |
|
48 | 48 | |
49 | - require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; |
|
50 | - $mailing = new Mailing($this->db); |
|
49 | + require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; |
|
50 | + $mailing = new Mailing($this->db); |
|
51 | 51 | |
52 | - $options = array(); |
|
52 | + $options = array(); |
|
53 | 53 | |
54 | - if ($show_empty) { |
|
55 | - $options[-2] = ''; // Note -1 is used for error |
|
56 | - } |
|
54 | + if ($show_empty) { |
|
55 | + $options[-2] = ''; // Note -1 is used for error |
|
56 | + } |
|
57 | 57 | |
58 | 58 | $options = $options + $mailing->statut_dest; |
59 | 59 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * \ingroup core |
21 | 21 | * \brief File of predefined functions for HTML forms for mailing module |
22 | 22 | */ |
23 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
23 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Class to offer components to list and upload files |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param integer $show_empty Show empty option |
41 | 41 | * @return string HTML select |
42 | 42 | */ |
43 | - public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
|
43 | + public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) |
|
44 | 44 | { |
45 | 45 | |
46 | 46 | global $langs; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $options = array(); |
53 | 53 | |
54 | 54 | if ($show_empty) { |
55 | - $options[-2] = ''; // Note -1 is used for error |
|
55 | + $options[-2] = ''; // Note -1 is used for error |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $options = $options + $mailing->statut_dest; |
@@ -70,8 +70,12 @@ discard block |
||
70 | 70 | |
71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
72 | 72 | |
73 | - if (! $rows) $rows=round($height/20); |
|
74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
73 | + if (! $rows) { |
|
74 | + $rows=round($height/20); |
|
75 | + } |
|
76 | + if (! $cols) { |
|
77 | + $cols=($width?round($width/6):80); |
|
78 | + } |
|
75 | 79 | $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
76 | 80 | |
77 | 81 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
@@ -81,8 +85,12 @@ discard block |
||
81 | 85 | $this->readonly=$readonly; |
82 | 86 | |
83 | 87 | // Check if extended editor is ok. If not we force textarea |
84 | - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
|
85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
88 | + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) { |
|
89 | + $this->tool = 'textarea'; |
|
90 | + } |
|
91 | + if ($okforextendededitor === 'ace') { |
|
92 | + $this->tool='ace'; |
|
93 | + } |
|
86 | 94 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
87 | 95 | |
88 | 96 | // Define content and some properties |
@@ -100,7 +108,9 @@ discard block |
||
100 | 108 | $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
101 | 109 | $this->editor->Value = $content; |
102 | 110 | $this->editor->Height = $height; |
103 | - if (! empty($width)) $this->editor->Width = $width; |
|
111 | + if (! empty($width)) { |
|
112 | + $this->editor->Width = $width; |
|
113 | + } |
|
104 | 114 | $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
105 | 115 | $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
106 | 116 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
@@ -163,9 +173,11 @@ discard block |
||
163 | 173 | $found=0; |
164 | 174 | $out=''; |
165 | 175 | |
166 | - if ($this->tool == 'fckeditor') // not used anymore |
|
176 | + if ($this->tool == 'fckeditor') { |
|
177 | + // not used anymore |
|
167 | 178 | { |
168 | 179 | $found=1; |
180 | + } |
|
169 | 181 | $this->editor->Create(); |
170 | 182 | } |
171 | 183 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,7 +191,9 @@ discard block |
||
179 | 191 | |
180 | 192 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
181 | 193 | { |
182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
194 | + if (! defined('REQUIRE_CKEDITOR')) { |
|
195 | + define('REQUIRE_CKEDITOR','1'); |
|
196 | + } |
|
183 | 197 | |
184 | 198 | if (! empty($conf->global->FCKEDITOR_SKIN)) { |
185 | 199 | $skin = $conf->global->FCKEDITOR_SKIN; |
@@ -343,7 +357,10 @@ discard block |
||
343 | 357 | $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
344 | 358 | } |
345 | 359 | |
346 | - if ($noprint) return $out; |
|
347 | - else print $out; |
|
360 | + if ($noprint) { |
|
361 | + return $out; |
|
362 | + } else { |
|
363 | + print $out; |
|
364 | + } |
|
348 | 365 | } |
349 | 366 | } |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | { |
31 | 31 | var $tool; // Store the selected tool |
32 | 32 | |
33 | - // If using fckeditor |
|
34 | - var $editor; |
|
33 | + // If using fckeditor |
|
34 | + var $editor; |
|
35 | 35 | |
36 | - // If not using fckeditor |
|
37 | - var $content; |
|
38 | - var $htmlname; |
|
39 | - var $toolbarname; |
|
40 | - var $toolbarstartexpanded; |
|
41 | - var $rows; |
|
42 | - var $cols; |
|
43 | - var $height; |
|
44 | - var $width; |
|
45 | - var $readonly; |
|
36 | + // If not using fckeditor |
|
37 | + var $content; |
|
38 | + var $htmlname; |
|
39 | + var $toolbarname; |
|
40 | + var $toolbarstartexpanded; |
|
41 | + var $rows; |
|
42 | + var $cols; |
|
43 | + var $height; |
|
44 | + var $width; |
|
45 | + var $readonly; |
|
46 | 46 | |
47 | 47 | |
48 | 48 | /** |
@@ -57,22 +57,22 @@ discard block |
||
57 | 57 | * 'In' each window has its own toolbar |
58 | 58 | * 'Out:name' share toolbar into the div called 'name' |
59 | 59 | * @param boolean $toolbarstartexpanded Bar is visible or not at start |
60 | - * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. |
|
61 | - * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. |
|
62 | - * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". |
|
60 | + * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. |
|
61 | + * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. |
|
62 | + * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". |
|
63 | 63 | * @param int $rows Size of rows for textarea tool |
64 | - * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
|
65 | - * @param int $readonly 0=Read/Edit, 1=Read only |
|
66 | - */ |
|
64 | + * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
|
65 | + * @param int $readonly 0=Read/Edit, 1=Read only |
|
66 | + */ |
|
67 | 67 | function __construct($htmlname, $content, $width='', $height=200, $toolbarname='Basic', $toolbarlocation='In', $toolbarstartexpanded=false, $uselocalbrowser=true, $okforextendededitor=true, $rows=0, $cols=0, $readonly=0) |
68 | 68 | { |
69 | - global $conf,$langs; |
|
69 | + global $conf,$langs; |
|
70 | 70 | |
71 | - dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
|
71 | + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
|
72 | 72 | |
73 | - if (! $rows) $rows=round($height/20); |
|
74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
75 | - $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
73 | + if (! $rows) $rows=round($height/20); |
|
74 | + if (! $cols) $cols=($width?round($width/6):80); |
|
75 | + $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
76 | 76 | |
77 | 77 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
78 | 78 | $defaulteditor='ckeditor'; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | // Check if extended editor is ok. If not we force textarea |
84 | 84 | if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
85 | + if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
86 | 86 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
87 | 87 | |
88 | 88 | // Define content and some properties |
@@ -91,50 +91,50 @@ discard block |
||
91 | 91 | $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
92 | 92 | } |
93 | 93 | if ($this->tool == 'fckeditor') |
94 | - { |
|
95 | - require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
|
96 | - |
|
97 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
98 | - |
|
99 | - $this->editor = new FCKeditor($htmlname); |
|
100 | - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
101 | - $this->editor->Value = $content; |
|
102 | - $this->editor->Height = $height; |
|
103 | - if (! empty($width)) $this->editor->Width = $width; |
|
104 | - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
105 | - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
106 | - $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
|
107 | - $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
|
108 | - |
|
109 | - // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
|
110 | - // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
|
111 | - // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
|
112 | - $modulepart='fckeditor'; |
|
113 | - $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
|
114 | - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
115 | - |
|
116 | - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
117 | - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
118 | - |
|
119 | - if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
|
120 | - { |
|
121 | - $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; |
|
122 | - $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - // Define some properties |
|
94 | + { |
|
95 | + require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
|
96 | + |
|
97 | + $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
98 | + |
|
99 | + $this->editor = new FCKeditor($htmlname); |
|
100 | + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
101 | + $this->editor->Value = $content; |
|
102 | + $this->editor->Height = $height; |
|
103 | + if (! empty($width)) $this->editor->Width = $width; |
|
104 | + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
105 | + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
106 | + $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
|
107 | + $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
|
108 | + |
|
109 | + // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
|
110 | + // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
|
111 | + // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
|
112 | + $modulepart='fckeditor'; |
|
113 | + $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
|
114 | + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
115 | + |
|
116 | + $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
117 | + $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
118 | + |
|
119 | + if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
|
120 | + { |
|
121 | + $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; |
|
122 | + $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + // Define some properties |
|
127 | 127 | if (in_array($this->tool,array('textarea','ckeditor','ace'))) |
128 | 128 | { |
129 | - $this->content = $content; |
|
130 | - $this->htmlname = $htmlname; |
|
131 | - $this->toolbarname = $shorttoolbarname; |
|
132 | - $this->toolbarstartexpanded = $toolbarstartexpanded; |
|
129 | + $this->content = $content; |
|
130 | + $this->htmlname = $htmlname; |
|
131 | + $this->toolbarname = $shorttoolbarname; |
|
132 | + $this->toolbarstartexpanded = $toolbarstartexpanded; |
|
133 | 133 | $this->rows = max(ROWS_3,$rows); |
134 | 134 | $this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max |
135 | 135 | $this->height = $height; |
136 | 136 | $this->width = $width; |
137 | - } |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='') |
153 | 153 | { |
154 | 154 | // phpcs:enable |
155 | - global $conf,$langs; |
|
155 | + global $conf,$langs; |
|
156 | 156 | |
157 | - $fullpage=false; |
|
158 | - if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
|
159 | - { |
|
160 | - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
161 | - } |
|
157 | + $fullpage=false; |
|
158 | + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
|
159 | + { |
|
160 | + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
161 | + } |
|
162 | 162 | |
163 | - $found=0; |
|
164 | - $out=''; |
|
163 | + $found=0; |
|
164 | + $out=''; |
|
165 | 165 | |
166 | 166 | if ($this->tool == 'fckeditor') // not used anymore |
167 | 167 | { |
168 | - $found=1; |
|
168 | + $found=1; |
|
169 | 169 | $this->editor->Create(); |
170 | 170 | } |
171 | 171 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | |
180 | 180 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
181 | 181 | { |
182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
182 | + if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
183 | 183 | |
184 | - if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
185 | - $skin = $conf->global->FCKEDITOR_SKIN; |
|
186 | - } else { |
|
187 | - // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
|
184 | + if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
185 | + $skin = $conf->global->FCKEDITOR_SKIN; |
|
186 | + } else { |
|
187 | + // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Alixar: |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
196 | 196 | } |
197 | 197 | |
198 | - $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
198 | + $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
199 | 199 | |
200 | - $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
201 | - $out.= '<script type="text/javascript"> |
|
200 | + $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
201 | + $out.= '<script type="text/javascript"> |
|
202 | 202 | $(document).ready(function () { |
203 | 203 | /* if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); */ |
204 | 204 | /* should be editor=CKEDITOR.replace but what if serveral editors ? */ |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | }); |
234 | 234 | } |
235 | 235 | }'; |
236 | - if ($this->uselocalbrowser) |
|
237 | - { |
|
236 | + if ($this->uselocalbrowser) |
|
237 | + { |
|
238 | 238 | $out.= ','."\n"; |
239 | 239 | // To use filemanager with old fckeditor (GPL) |
240 | 240 | $out.= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | //$out.= ' filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\','; |
244 | 244 | $out.= "\n"; |
245 | 245 | // To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes |
246 | - /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
|
246 | + /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
|
247 | 247 | filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\', |
248 | 248 | filebrowserFlashBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Flash\', |
249 | 249 | filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files\', |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | filebrowserWindowHeight : \'500\', |
255 | 255 | filebrowserImageWindowWidth : \'900\', |
256 | 256 | filebrowserImageWindowHeight : \'500\''; |
257 | - } |
|
258 | - $out.= ' })'.$morejs; |
|
259 | - $out.= '});'."\n"; |
|
260 | - $out.= '</script>'."\n"; |
|
257 | + } |
|
258 | + $out.= ' })'.$morejs; |
|
259 | + $out.= '});'."\n"; |
|
260 | + $out.= '</script>'."\n"; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. |
266 | 266 | if (preg_match('/^ace/', $this->tool)) |
267 | 267 | { |
268 | - $found=1; |
|
269 | - $format=$option; |
|
268 | + $found=1; |
|
269 | + $format=$option; |
|
270 | 270 | |
271 | 271 | $out.= "\n".'<!-- Output Ace editor -->'."\n"; |
272 | 272 | |
273 | - if ($titlecontent) |
|
274 | - { |
|
275 | - $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
276 | - $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
277 | - $out.= '</div>'; |
|
278 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
279 | - $out.= 'jQuery(document).ready(function() {'."\n"; |
|
280 | - $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
273 | + if ($titlecontent) |
|
274 | + { |
|
275 | + $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
276 | + $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
277 | + $out.= '</div>'; |
|
278 | + $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
279 | + $out.= 'jQuery(document).ready(function() {'."\n"; |
|
280 | + $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
281 | 281 | var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar |
282 | 282 | var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar |
283 | 283 | var oldNbOfLines = 0 |
@@ -299,21 +299,21 @@ discard block |
||
299 | 299 | } |
300 | 300 | }); |
301 | 301 | })'; |
302 | - $out.= '</script>'."\n"; |
|
303 | - } |
|
302 | + $out.= '</script>'."\n"; |
|
303 | + } |
|
304 | 304 | |
305 | 305 | $out.= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':''); |
306 | 306 | $out.= ($this->height?' height: '.$this->height.'px; ':''); |
307 | 307 | //$out.=" min-height: 100px;"; |
308 | 308 | $out.= '">'; |
309 | - $out.= htmlspecialchars($this->content); |
|
310 | - $out.= '</pre>'; |
|
311 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
312 | - $out.= htmlspecialchars($this->content); |
|
313 | - $out.= '</textarea>'; |
|
309 | + $out.= htmlspecialchars($this->content); |
|
310 | + $out.= '</pre>'; |
|
311 | + $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
312 | + $out.= htmlspecialchars($this->content); |
|
313 | + $out.= '</textarea>'; |
|
314 | 314 | |
315 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
316 | - $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
315 | + $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
316 | + $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
317 | 317 | |
318 | 318 | aceEditor.session.setMode("ace/mode/'.$format.'"); |
319 | 319 | aceEditor.setOptions({ |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | //aceEditor.getSession().setMode("ace/mode/javascript_expression"); |
334 | 334 | '."\n"; |
335 | 335 | |
336 | - $out.= 'jQuery(document).ready(function() { |
|
336 | + $out.= 'jQuery(document).ready(function() { |
|
337 | 337 | jQuery(".buttonforacesave").click(function() { |
338 | 338 | console.log("We click on savefile button for component '.$this->htmlname.'"); |
339 | 339 | var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid") |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | else return false;*/ |
344 | 344 | }); |
345 | 345 | })'; |
346 | - $out.= '</script>'."\n"; |
|
346 | + $out.= '</script>'."\n"; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | if (empty($found)) |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class DolEditor |
30 | 30 | { |
31 | - var $tool; // Store the selected tool |
|
31 | + var $tool; // Store the selected tool |
|
32 | 32 | |
33 | 33 | // If using fckeditor |
34 | 34 | var $editor; |
@@ -64,57 +64,57 @@ discard block |
||
64 | 64 | * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
65 | 65 | * @param int $readonly 0=Read/Edit, 1=Read only |
66 | 66 | */ |
67 | - function __construct($htmlname, $content, $width='', $height=200, $toolbarname='Basic', $toolbarlocation='In', $toolbarstartexpanded=false, $uselocalbrowser=true, $okforextendededitor=true, $rows=0, $cols=0, $readonly=0) |
|
67 | + function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) |
|
68 | 68 | { |
69 | - global $conf,$langs; |
|
69 | + global $conf, $langs; |
|
70 | 70 | |
71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
72 | 72 | |
73 | - if (! $rows) $rows=round($height/20); |
|
74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
75 | - $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
73 | + if (!$rows) $rows = round($height / 20); |
|
74 | + if (!$cols) $cols = ($width ?round($width / 6) : 80); |
|
75 | + $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); |
|
76 | 76 | |
77 | 77 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
78 | - $defaulteditor='ckeditor'; |
|
79 | - $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; |
|
80 | - $this->uselocalbrowser=$uselocalbrowser; |
|
81 | - $this->readonly=$readonly; |
|
78 | + $defaulteditor = 'ckeditor'; |
|
79 | + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; |
|
80 | + $this->uselocalbrowser = $uselocalbrowser; |
|
81 | + $this->readonly = $readonly; |
|
82 | 82 | |
83 | 83 | // Check if extended editor is ok. If not we force textarea |
84 | 84 | if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
85 | + if ($okforextendededitor === 'ace') $this->tool = 'ace'; |
|
86 | 86 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
87 | 87 | |
88 | 88 | // Define content and some properties |
89 | 89 | if ($this->tool == 'ckeditor') |
90 | 90 | { |
91 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
91 | + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
92 | 92 | } |
93 | 93 | if ($this->tool == 'fckeditor') |
94 | 94 | { |
95 | 95 | require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
96 | 96 | |
97 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
97 | + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
98 | 98 | |
99 | 99 | $this->editor = new FCKeditor($htmlname); |
100 | - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
101 | - $this->editor->Value = $content; |
|
100 | + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/'; |
|
101 | + $this->editor->Value = $content; |
|
102 | 102 | $this->editor->Height = $height; |
103 | - if (! empty($width)) $this->editor->Width = $width; |
|
104 | - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
105 | - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
103 | + if (!empty($width)) $this->editor->Width = $width; |
|
104 | + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
105 | + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
106 | 106 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
107 | 107 | $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
108 | 108 | |
109 | 109 | // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
110 | 110 | // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
111 | 111 | // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
112 | - $modulepart='fckeditor'; |
|
112 | + $modulepart = 'fckeditor'; |
|
113 | 113 | $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
114 | - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
114 | + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/'; |
|
115 | 115 | |
116 | - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
117 | - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
116 | + $this->editor->Config['LinkBrowser'] = ($uselocalbrowser ? 'true' : 'false'); |
|
117 | + $this->editor->Config['ImageBrowser'] = ($uselocalbrowser ? 'true' : 'false'); |
|
118 | 118 | |
119 | 119 | if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
120 | 120 | { |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | // Define some properties |
127 | - if (in_array($this->tool,array('textarea','ckeditor','ace'))) |
|
127 | + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) |
|
128 | 128 | { |
129 | - $this->content = $content; |
|
129 | + $this->content = $content; |
|
130 | 130 | $this->htmlname = $htmlname; |
131 | - $this->toolbarname = $shorttoolbarname; |
|
131 | + $this->toolbarname = $shorttoolbarname; |
|
132 | 132 | $this->toolbarstartexpanded = $toolbarstartexpanded; |
133 | - $this->rows = max(ROWS_3,$rows); |
|
134 | - $this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max |
|
135 | - $this->height = $height; |
|
133 | + $this->rows = max(ROWS_3, $rows); |
|
134 | + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max |
|
135 | + $this->height = $height; |
|
136 | 136 | $this->width = $width; |
137 | 137 | } |
138 | 138 | } |
@@ -149,39 +149,39 @@ discard block |
||
149 | 149 | * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) |
150 | 150 | * @return void|string |
151 | 151 | */ |
152 | - function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='') |
|
152 | + function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') |
|
153 | 153 | { |
154 | 154 | // phpcs:enable |
155 | - global $conf,$langs; |
|
155 | + global $conf, $langs; |
|
156 | 156 | |
157 | - $fullpage=false; |
|
157 | + $fullpage = false; |
|
158 | 158 | if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
159 | 159 | { |
160 | - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
160 | + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
161 | 161 | } |
162 | 162 | |
163 | - $found=0; |
|
164 | - $out=''; |
|
163 | + $found = 0; |
|
164 | + $out = ''; |
|
165 | 165 | |
166 | 166 | if ($this->tool == 'fckeditor') // not used anymore |
167 | 167 | { |
168 | - $found=1; |
|
168 | + $found = 1; |
|
169 | 169 | $this->editor->Create(); |
170 | 170 | } |
171 | - if (in_array($this->tool,array('textarea','ckeditor'))) |
|
171 | + if (in_array($this->tool, array('textarea', 'ckeditor'))) |
|
172 | 172 | { |
173 | - $found=1; |
|
173 | + $found = 1; |
|
174 | 174 | //$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">'; |
175 | 175 | // TODO We do not put the disabled tag because on a read form, it change style with grey. |
176 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">'; |
|
177 | - $out.= $this->content; |
|
178 | - $out.= '</textarea>'; |
|
176 | + $out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/', $this->cols) ? ' style="margin-top: 5px; width: '.$this->cols.'"' : ' cols="'.$this->cols.'"').' class="flat">'; |
|
177 | + $out .= $this->content; |
|
178 | + $out .= '</textarea>'; |
|
179 | 179 | |
180 | - if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
|
180 | + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax)) |
|
181 | 181 | { |
182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
182 | + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); |
|
183 | 183 | |
184 | - if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
184 | + if (!empty($conf->global->FCKEDITOR_SKIN)) { |
|
185 | 185 | $skin = $conf->global->FCKEDITOR_SKIN; |
186 | 186 | } else { |
187 | 187 | // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * When updating ckeditor, the moono-lisa skin disappears |
193 | 193 | * and includes kama and moono. |
194 | 194 | */ |
195 | - $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
|
195 | + $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
|
196 | 196 | } |
197 | 197 | |
198 | - $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
198 | + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; |
|
199 | 199 | |
200 | - $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
201 | - $out.= '<script type="text/javascript"> |
|
200 | + $out .= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
201 | + $out .= '<script type="text/javascript"> |
|
202 | 202 | $(document).ready(function () { |
203 | 203 | /* if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); */ |
204 | 204 | /* should be editor=CKEDITOR.replace but what if serveral editors ? */ |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | { |
207 | 207 | /* property:xxx is same than CKEDITOR.config.property = xxx */ |
208 | 208 | customConfig : ckeditorConfig, |
209 | - readOnly : '.($this->readonly?'true':'false').', |
|
209 | + readOnly : '.($this->readonly ? 'true' : 'false').', |
|
210 | 210 | htmlEncodeOutput :'.$htmlencode_force.', |
211 | - allowedContent :'.($disallowAnyContent?'false':'true').', |
|
211 | + allowedContent :'.($disallowAnyContent ? 'false' : 'true').', |
|
212 | 212 | extraAllowedContent : \'\', |
213 | - fullPage : '.($fullpage?'true':'false').', |
|
213 | + fullPage : '.($fullpage ? 'true' : 'false').', |
|
214 | 214 | toolbar: \''.$this->toolbarname.'\', |
215 | 215 | toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').', |
216 | 216 | width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').', |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | }'; |
236 | 236 | if ($this->uselocalbrowser) |
237 | 237 | { |
238 | - $out.= ','."\n"; |
|
238 | + $out .= ','."\n"; |
|
239 | 239 | // To use filemanager with old fckeditor (GPL) |
240 | - $out.= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
|
241 | - $out.= ' filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,'; |
|
240 | + $out .= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
|
241 | + $out .= ' filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,'; |
|
242 | 242 | //$out.= ' filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=File\','; |
243 | 243 | //$out.= ' filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\','; |
244 | - $out.= "\n"; |
|
244 | + $out .= "\n"; |
|
245 | 245 | // To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes |
246 | 246 | /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
247 | 247 | filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\', |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images\', |
251 | 251 | filebrowserFlashUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash\','."\n"; |
252 | 252 | */ |
253 | - $out.= ' filebrowserWindowWidth : \'900\', |
|
253 | + $out .= ' filebrowserWindowWidth : \'900\', |
|
254 | 254 | filebrowserWindowHeight : \'500\', |
255 | 255 | filebrowserImageWindowWidth : \'900\', |
256 | 256 | filebrowserImageWindowHeight : \'500\''; |
257 | 257 | } |
258 | - $out.= ' })'.$morejs; |
|
259 | - $out.= '});'."\n"; |
|
260 | - $out.= '</script>'."\n"; |
|
258 | + $out .= ' })'.$morejs; |
|
259 | + $out .= '});'."\n"; |
|
260 | + $out .= '</script>'."\n"; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. |
266 | 266 | if (preg_match('/^ace/', $this->tool)) |
267 | 267 | { |
268 | - $found=1; |
|
269 | - $format=$option; |
|
268 | + $found = 1; |
|
269 | + $format = $option; |
|
270 | 270 | |
271 | - $out.= "\n".'<!-- Output Ace editor -->'."\n"; |
|
271 | + $out .= "\n".'<!-- Output Ace editor -->'."\n"; |
|
272 | 272 | |
273 | 273 | if ($titlecontent) |
274 | 274 | { |
275 | - $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
276 | - $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
277 | - $out.= '</div>'; |
|
278 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
279 | - $out.= 'jQuery(document).ready(function() {'."\n"; |
|
280 | - $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
275 | + $out .= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
276 | + $out .= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
277 | + $out .= '</div>'; |
|
278 | + $out .= '<script type="text/javascript" language="javascript">'."\n"; |
|
279 | + $out .= 'jQuery(document).ready(function() {'."\n"; |
|
280 | + $out .= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
281 | 281 | var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar |
282 | 282 | var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar |
283 | 283 | var oldNbOfLines = 0 |
@@ -299,21 +299,21 @@ discard block |
||
299 | 299 | } |
300 | 300 | }); |
301 | 301 | })'; |
302 | - $out.= '</script>'."\n"; |
|
302 | + $out .= '</script>'."\n"; |
|
303 | 303 | } |
304 | 304 | |
305 | - $out.= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':''); |
|
306 | - $out.= ($this->height?' height: '.$this->height.'px; ':''); |
|
305 | + $out .= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width ? 'width: '.$this->width.'px; ' : ''); |
|
306 | + $out .= ($this->height ? ' height: '.$this->height.'px; ' : ''); |
|
307 | 307 | //$out.=" min-height: 100px;"; |
308 | - $out.= '">'; |
|
309 | - $out.= htmlspecialchars($this->content); |
|
310 | - $out.= '</pre>'; |
|
311 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
312 | - $out.= htmlspecialchars($this->content); |
|
313 | - $out.= '</textarea>'; |
|
308 | + $out .= '">'; |
|
309 | + $out .= htmlspecialchars($this->content); |
|
310 | + $out .= '</pre>'; |
|
311 | + $out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
312 | + $out .= htmlspecialchars($this->content); |
|
313 | + $out .= '</textarea>'; |
|
314 | 314 | |
315 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
316 | - $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
315 | + $out .= '<script type="text/javascript" language="javascript">'."\n"; |
|
316 | + $out .= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
317 | 317 | |
318 | 318 | aceEditor.session.setMode("ace/mode/'.$format.'"); |
319 | 319 | aceEditor.setOptions({ |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | enableLiveAutocompletion: false, // the editor completes the statement while you are typing. Need lib ext-language_tools.js |
322 | 322 | showPrintMargin: false, // hides the vertical limiting strip |
323 | 323 | minLines: 10, |
324 | - maxLines: '.(empty($this->height)?'34':(round($this->height/10))).', |
|
324 | + maxLines: '.(empty($this->height) ? '34' : (round($this->height / 10))).', |
|
325 | 325 | fontSize: "110%" // ensures that the editor fits in the environment |
326 | 326 | }); |
327 | 327 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | //aceEditor.getSession().setMode("ace/mode/javascript_expression"); |
334 | 334 | '."\n"; |
335 | 335 | |
336 | - $out.= 'jQuery(document).ready(function() { |
|
336 | + $out .= 'jQuery(document).ready(function() { |
|
337 | 337 | jQuery(".buttonforacesave").click(function() { |
338 | 338 | console.log("We click on savefile button for component '.$this->htmlname.'"); |
339 | 339 | var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid") |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | else return false;*/ |
344 | 344 | }); |
345 | 345 | })'; |
346 | - $out.= '</script>'."\n"; |
|
346 | + $out .= '</script>'."\n"; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | if (empty($found)) |
350 | 350 | { |
351 | - $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
|
351 | + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | if ($noprint) return $out; |