@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | function payment_prepare_head(Paiement $object) |
29 | 29 | { |
30 | 30 | |
31 | - global $langs, $conf; |
|
31 | + global $langs, $conf; |
|
32 | 32 | |
33 | - $h = 0; |
|
34 | - $head = array(); |
|
33 | + $h = 0; |
|
34 | + $head = array(); |
|
35 | 35 | |
36 | - $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id; |
|
37 | - $head[$h][1] = $langs->trans("Card"); |
|
38 | - $head[$h][2] = 'payment'; |
|
39 | - $h++; |
|
36 | + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id; |
|
37 | + $head[$h][1] = $langs->trans("Card"); |
|
38 | + $head[$h][2] = 'payment'; |
|
39 | + $h++; |
|
40 | 40 | |
41 | 41 | // Show more tabs from modules |
42 | 42 | // Entries must be declared in modules descriptor with line |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | // $this->tabs = array('entity:-tabname); to remove a tab |
45 | 45 | complete_head_from_modules($conf,$langs,$object,$head,$h,'payment'); |
46 | 46 | |
47 | - $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; |
|
48 | - $head[$h][1] = $langs->trans("Info"); |
|
49 | - $head[$h][2] = 'info'; |
|
50 | - $h++; |
|
47 | + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; |
|
48 | + $head[$h][1] = $langs->trans("Info"); |
|
49 | + $head[$h][2] = 'info'; |
|
50 | + $h++; |
|
51 | 51 | |
52 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment', 'remove'); |
|
52 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment', 'remove'); |
|
53 | 53 | |
54 | - return $head; |
|
54 | + return $head; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function payment_supplier_prepare_head(Paiement $object) |
65 | 65 | { |
66 | - global $langs, $conf; |
|
66 | + global $langs, $conf; |
|
67 | 67 | |
68 | - $h = 0; |
|
69 | - $head = array(); |
|
68 | + $h = 0; |
|
69 | + $head = array(); |
|
70 | 70 | |
71 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$object->id; |
|
72 | - $head[$h][1] = $langs->trans("Card"); |
|
73 | - $head[$h][2] = 'payment'; |
|
74 | - $h++; |
|
71 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$object->id; |
|
72 | + $head[$h][1] = $langs->trans("Card"); |
|
73 | + $head[$h][2] = 'payment'; |
|
74 | + $h++; |
|
75 | 75 | |
76 | 76 | // Show more tabs from modules |
77 | 77 | // Entries must be declared in modules descriptor with line |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | // $this->tabs = array('entity:-tabname); to remove a tab |
80 | 80 | complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier'); |
81 | 81 | |
82 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id; |
|
83 | - $head[$h][1] = $langs->trans('Info'); |
|
84 | - $head[$h][2] = 'info'; |
|
85 | - $h++; |
|
82 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id; |
|
83 | + $head[$h][1] = $langs->trans('Info'); |
|
84 | + $head[$h][2] = 'info'; |
|
85 | + $h++; |
|
86 | 86 | |
87 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier', 'remove'); |
|
87 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier', 'remove'); |
|
88 | 88 | |
89 | - return $head; |
|
89 | + return $head; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function getValidOnlinePaymentMethods($paymentmethod='') |
99 | 99 | { |
100 | - global $conf; |
|
101 | - |
|
102 | - $validpaymentmethod=array(); |
|
103 | - |
|
104 | - if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) |
|
105 | - { |
|
106 | - $validpaymentmethod['paypal']='valid'; |
|
107 | - } |
|
108 | - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) |
|
109 | - { |
|
110 | - $validpaymentmethod['paybox']='valid'; |
|
111 | - } |
|
112 | - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) |
|
113 | - { |
|
114 | - $validpaymentmethod['stripe']='valid'; |
|
115 | - } |
|
116 | - return $validpaymentmethod; |
|
100 | + global $conf; |
|
101 | + |
|
102 | + $validpaymentmethod=array(); |
|
103 | + |
|
104 | + if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) |
|
105 | + { |
|
106 | + $validpaymentmethod['paypal']='valid'; |
|
107 | + } |
|
108 | + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) |
|
109 | + { |
|
110 | + $validpaymentmethod['paybox']='valid'; |
|
111 | + } |
|
112 | + if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) |
|
113 | + { |
|
114 | + $validpaymentmethod['stripe']='valid'; |
|
115 | + } |
|
116 | + return $validpaymentmethod; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function showOnlinePaymentUrl($type,$ref) |
127 | 127 | { |
128 | - global $conf, $langs; |
|
128 | + global $conf, $langs; |
|
129 | 129 | |
130 | - // Load translation files required by the page |
|
130 | + // Load translation files required by the page |
|
131 | 131 | $langs->loadLangs(array('payment', 'paybox')); |
132 | 132 | |
133 | - $servicename='Online'; |
|
133 | + $servicename='Online'; |
|
134 | 134 | |
135 | - $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>'; |
|
136 | - $url = getOnlinePaymentUrl(0,$type,$ref); |
|
137 | - $out.= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">'; |
|
138 | - $out.= ajax_autoselect("onlinepaymenturl", 0); |
|
139 | - return $out; |
|
135 | + $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>'; |
|
136 | + $url = getOnlinePaymentUrl(0,$type,$ref); |
|
137 | + $out.= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">'; |
|
138 | + $out.= ajax_autoselect("onlinepaymenturl", 0); |
|
139 | + return $out; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -151,115 +151,115 @@ discard block |
||
151 | 151 | */ |
152 | 152 | function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='your_free_tag') |
153 | 153 | { |
154 | - global $conf; |
|
155 | - |
|
156 | - $ref=str_replace(' ','',$ref); |
|
157 | - $out=''; |
|
158 | - |
|
159 | - if ($type == 'free') |
|
160 | - { |
|
161 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':''); |
|
162 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
163 | - { |
|
164 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
165 | - else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
166 | - } |
|
167 | - } |
|
168 | - elseif ($type == 'order') |
|
169 | - { |
|
170 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':''); |
|
171 | - if ($mode == 1) $out.='order_ref'; |
|
172 | - if ($mode == 0) $out.=urlencode($ref); |
|
173 | - $out.=($mode?'</font>':''); |
|
174 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
175 | - { |
|
176 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
177 | - else |
|
178 | - { |
|
179 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
180 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
181 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
182 | - $out.=($mode?'</font>':''); |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - elseif ($type == 'invoice') |
|
187 | - { |
|
188 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':''); |
|
189 | - if ($mode == 1) $out.='invoice_ref'; |
|
190 | - if ($mode == 0) $out.=urlencode($ref); |
|
191 | - $out.=($mode?'</font>':''); |
|
192 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
193 | - { |
|
194 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
195 | - else |
|
196 | - { |
|
197 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
198 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
199 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
200 | - $out.=($mode?'</font>':''); |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - elseif ($type == 'contractline') |
|
205 | - { |
|
206 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':''); |
|
207 | - if ($mode == 1) $out.='contractline_ref'; |
|
208 | - if ($mode == 0) $out.=urlencode($ref); |
|
209 | - $out.=($mode?'</font>':''); |
|
210 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
211 | - { |
|
212 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
213 | - else |
|
214 | - { |
|
215 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
216 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
217 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
218 | - $out.=($mode?'</font>':''); |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - elseif ($type == 'member' || $type == 'membersubscription') |
|
223 | - { |
|
224 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':''); |
|
225 | - if ($mode == 1) $out.='member_ref'; |
|
226 | - if ($mode == 0) $out.=urlencode($ref); |
|
227 | - $out.=($mode?'</font>':''); |
|
228 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
229 | - { |
|
230 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
231 | - else |
|
232 | - { |
|
233 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
234 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
235 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
236 | - $out.=($mode?'</font>':''); |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
240 | - if ($type == 'donation') |
|
241 | - { |
|
242 | - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'<font color="#666666">':''); |
|
243 | - if ($mode == 1) $out.='donation_ref'; |
|
244 | - if ($mode == 0) $out.=urlencode($ref); |
|
245 | - $out.=($mode?'</font>':''); |
|
246 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
247 | - { |
|
248 | - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
249 | - else |
|
250 | - { |
|
251 | - $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
252 | - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; |
|
253 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
254 | - $out.=($mode?'</font>':''); |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - // For multicompany |
|
260 | - if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities |
|
261 | - |
|
262 | - return $out; |
|
154 | + global $conf; |
|
155 | + |
|
156 | + $ref=str_replace(' ','',$ref); |
|
157 | + $out=''; |
|
158 | + |
|
159 | + if ($type == 'free') |
|
160 | + { |
|
161 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':''); |
|
162 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
163 | + { |
|
164 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
165 | + else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); |
|
166 | + } |
|
167 | + } |
|
168 | + elseif ($type == 'order') |
|
169 | + { |
|
170 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':''); |
|
171 | + if ($mode == 1) $out.='order_ref'; |
|
172 | + if ($mode == 0) $out.=urlencode($ref); |
|
173 | + $out.=($mode?'</font>':''); |
|
174 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
175 | + { |
|
176 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
177 | + else |
|
178 | + { |
|
179 | + $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
180 | + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
181 | + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
182 | + $out.=($mode?'</font>':''); |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + elseif ($type == 'invoice') |
|
187 | + { |
|
188 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':''); |
|
189 | + if ($mode == 1) $out.='invoice_ref'; |
|
190 | + if ($mode == 0) $out.=urlencode($ref); |
|
191 | + $out.=($mode?'</font>':''); |
|
192 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
193 | + { |
|
194 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
195 | + else |
|
196 | + { |
|
197 | + $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
198 | + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
199 | + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
200 | + $out.=($mode?'</font>':''); |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + elseif ($type == 'contractline') |
|
205 | + { |
|
206 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':''); |
|
207 | + if ($mode == 1) $out.='contractline_ref'; |
|
208 | + if ($mode == 0) $out.=urlencode($ref); |
|
209 | + $out.=($mode?'</font>':''); |
|
210 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
211 | + { |
|
212 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
213 | + else |
|
214 | + { |
|
215 | + $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
216 | + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
217 | + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
218 | + $out.=($mode?'</font>':''); |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + elseif ($type == 'member' || $type == 'membersubscription') |
|
223 | + { |
|
224 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':''); |
|
225 | + if ($mode == 1) $out.='member_ref'; |
|
226 | + if ($mode == 0) $out.=urlencode($ref); |
|
227 | + $out.=($mode?'</font>':''); |
|
228 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
229 | + { |
|
230 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
231 | + else |
|
232 | + { |
|
233 | + $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
234 | + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
235 | + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
236 | + $out.=($mode?'</font>':''); |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | + if ($type == 'donation') |
|
241 | + { |
|
242 | + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'<font color="#666666">':''); |
|
243 | + if ($mode == 1) $out.='donation_ref'; |
|
244 | + if ($mode == 0) $out.=urlencode($ref); |
|
245 | + $out.=($mode?'</font>':''); |
|
246 | + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
247 | + { |
|
248 | + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; |
|
249 | + else |
|
250 | + { |
|
251 | + $out.='&securekey='.($mode?'<font color="#666666">':''); |
|
252 | + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; |
|
253 | + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); |
|
254 | + $out.=($mode?'</font>':''); |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + // For multicompany |
|
260 | + if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities |
|
261 | + |
|
262 | + return $out; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -331,20 +331,20 @@ discard block |
||
331 | 331 | print '<div class="center">'."\n"; |
332 | 332 | if ($addformmessage) |
333 | 333 | { |
334 | - print '<!-- object = '.$object->element.' -->'; |
|
335 | - print '<br>'; |
|
336 | - |
|
337 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
338 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
339 | - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
340 | - |
|
341 | - // Add other message if VAT exists |
|
342 | - if ($object->total_vat != 0 || $object->total_tva != 0) |
|
343 | - { |
|
344 | - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
345 | - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
346 | - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
347 | - } |
|
334 | + print '<!-- object = '.$object->element.' -->'; |
|
335 | + print '<br>'; |
|
336 | + |
|
337 | + $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; |
|
338 | + if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
339 | + elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); |
|
340 | + |
|
341 | + // Add other message if VAT exists |
|
342 | + if ($object->total_vat != 0 || $object->total_tva != 0) |
|
343 | + { |
|
344 | + $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; |
|
345 | + if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); |
|
346 | + elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | print '<font style="font-size: 10px;"><br><hr>'."\n"; |
@@ -28,41 +28,41 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function asset_admin_prepare_head() |
30 | 30 | { |
31 | - global $langs, $conf; |
|
31 | + global $langs, $conf; |
|
32 | 32 | |
33 | - $langs->load("assets"); |
|
33 | + $langs->load("assets"); |
|
34 | 34 | |
35 | - $h = 0; |
|
36 | - $head = array(); |
|
35 | + $h = 0; |
|
36 | + $head = array(); |
|
37 | 37 | |
38 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; |
|
39 | - $head[$h][1] = $langs->trans("Settings"); |
|
40 | - $head[$h][2] = 'settings'; |
|
41 | - $h++; |
|
38 | + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; |
|
39 | + $head[$h][1] = $langs->trans("Settings"); |
|
40 | + $head[$h][2] = 'settings'; |
|
41 | + $h++; |
|
42 | 42 | |
43 | - // Show more tabs from modules |
|
44 | - // Entries must be declared in modules descriptor with line |
|
45 | - //$this->tabs = array( |
|
46 | - // 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__' |
|
47 | - //); // to add new tab |
|
48 | - //$this->tabs = array( |
|
49 | - // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' |
|
50 | - //); // to remove a tab |
|
51 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); |
|
43 | + // Show more tabs from modules |
|
44 | + // Entries must be declared in modules descriptor with line |
|
45 | + //$this->tabs = array( |
|
46 | + // 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__' |
|
47 | + //); // to add new tab |
|
48 | + //$this->tabs = array( |
|
49 | + // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' |
|
50 | + //); // to remove a tab |
|
51 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); |
|
52 | 52 | |
53 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; |
|
54 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
55 | - $head[$h][2] = 'attributes'; |
|
56 | - $h++; |
|
53 | + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; |
|
54 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
55 | + $head[$h][2] = 'attributes'; |
|
56 | + $h++; |
|
57 | 57 | |
58 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; |
|
59 | - $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); |
|
60 | - $head[$h][2] = 'attributes_type'; |
|
61 | - $h++; |
|
58 | + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; |
|
59 | + $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); |
|
60 | + $head[$h][2] = 'attributes_type'; |
|
61 | + $h++; |
|
62 | 62 | |
63 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove'); |
|
63 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove'); |
|
64 | 64 | |
65 | - return $head; |
|
65 | + return $head; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,56 +72,56 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function asset_prepare_head() |
74 | 74 | { |
75 | - global $langs, $conf; |
|
76 | - |
|
77 | - $langs->load("assets"); |
|
78 | - |
|
79 | - $h = 0; |
|
80 | - $head = array(); |
|
81 | - |
|
82 | - $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; |
|
83 | - $head[$h][1] = $langs->trans("Card"); |
|
84 | - $head[$h][2] = 'card'; |
|
85 | - $h++; |
|
86 | - |
|
87 | - // Show more tabs from modules |
|
88 | - // Entries must be declared in modules descriptor with line |
|
89 | - //$this->tabs = array( |
|
90 | - // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' |
|
91 | - //); // to add new tab |
|
92 | - //$this->tabs = array( |
|
93 | - // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' |
|
94 | - //); // to remove a tab |
|
95 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets'); |
|
96 | - |
|
97 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
98 | - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
99 | - $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref); |
|
100 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
101 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
102 | - $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; |
|
103 | - $head[$h][1] = $langs->trans('Documents'); |
|
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | - $head[$h][2] = 'documents'; |
|
106 | - $h++; |
|
107 | - |
|
108 | - $nbNote = 0; |
|
109 | - if(!empty($object->note_private)) $nbNote++; |
|
110 | - if(!empty($object->note_public)) $nbNote++; |
|
111 | - $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; |
|
112 | - $head[$h][1] = $langs->trans("Notes"); |
|
113 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
114 | - $head[$h][2] = 'note'; |
|
115 | - $h++; |
|
116 | - |
|
117 | - $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; |
|
118 | - $head[$h][1] = $langs->trans("Info"); |
|
119 | - $head[$h][2] = 'info'; |
|
120 | - $h++; |
|
121 | - |
|
122 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'asset', 'remove'); |
|
123 | - |
|
124 | - return $head; |
|
75 | + global $langs, $conf; |
|
76 | + |
|
77 | + $langs->load("assets"); |
|
78 | + |
|
79 | + $h = 0; |
|
80 | + $head = array(); |
|
81 | + |
|
82 | + $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; |
|
83 | + $head[$h][1] = $langs->trans("Card"); |
|
84 | + $head[$h][2] = 'card'; |
|
85 | + $h++; |
|
86 | + |
|
87 | + // Show more tabs from modules |
|
88 | + // Entries must be declared in modules descriptor with line |
|
89 | + //$this->tabs = array( |
|
90 | + // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' |
|
91 | + //); // to add new tab |
|
92 | + //$this->tabs = array( |
|
93 | + // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' |
|
94 | + //); // to remove a tab |
|
95 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets'); |
|
96 | + |
|
97 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
98 | + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
99 | + $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref); |
|
100 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
101 | + $nbLinks=Link::count($db, $object->element, $object->id); |
|
102 | + $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; |
|
103 | + $head[$h][1] = $langs->trans('Documents'); |
|
104 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | + $head[$h][2] = 'documents'; |
|
106 | + $h++; |
|
107 | + |
|
108 | + $nbNote = 0; |
|
109 | + if(!empty($object->note_private)) $nbNote++; |
|
110 | + if(!empty($object->note_public)) $nbNote++; |
|
111 | + $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; |
|
112 | + $head[$h][1] = $langs->trans("Notes"); |
|
113 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
114 | + $head[$h][2] = 'note'; |
|
115 | + $h++; |
|
116 | + |
|
117 | + $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; |
|
118 | + $head[$h][1] = $langs->trans("Info"); |
|
119 | + $head[$h][2] = 'info'; |
|
120 | + $h++; |
|
121 | + |
|
122 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'asset', 'remove'); |
|
123 | + |
|
124 | + return $head; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function asset_type_prepare_head(AssetType $object) |
134 | 134 | { |
135 | - global $langs, $conf, $user; |
|
135 | + global $langs, $conf, $user; |
|
136 | 136 | |
137 | - $h=0; |
|
138 | - $head = array(); |
|
137 | + $h=0; |
|
138 | + $head = array(); |
|
139 | 139 | |
140 | - $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; |
|
141 | - $head[$h][1] = $langs->trans("Card"); |
|
142 | - $head[$h][2] = 'card'; |
|
143 | - $h++; |
|
140 | + $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; |
|
141 | + $head[$h][1] = $langs->trans("Card"); |
|
142 | + $head[$h][2] = 'card'; |
|
143 | + $h++; |
|
144 | 144 | |
145 | - // Show more tabs from modules |
|
146 | - // Entries must be declared in modules descriptor with line |
|
147 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
148 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
149 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype'); |
|
145 | + // Show more tabs from modules |
|
146 | + // Entries must be declared in modules descriptor with line |
|
147 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
148 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
149 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype'); |
|
150 | 150 | |
151 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove'); |
|
151 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove'); |
|
152 | 152 | |
153 | - return $head; |
|
153 | + return $head; |
|
154 | 154 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | $tab = 0; |
37 | 37 | $head = array(); |
38 | 38 | |
39 | - $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id; |
|
40 | - $head[$tab][1] = $langs->trans('Card'); |
|
41 | - $head[$tab][2] = 'card'; |
|
42 | - $tab++; |
|
39 | + $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id; |
|
40 | + $head[$tab][1] = $langs->trans('Card'); |
|
41 | + $head[$tab][2] = 'card'; |
|
42 | + $tab++; |
|
43 | 43 | |
44 | 44 | // Show more tabs from modules |
45 | 45 | // Entries must be declared in modules descriptor with line |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | // $this->tabs = array('entity:-tabname); to remove a tab |
48 | 48 | complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat'); |
49 | 49 | |
50 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
50 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
51 | 51 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
52 | - $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
53 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
52 | + $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
53 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
54 | 54 | $nbLinks=Link::count($db, $object->element, $object->id); |
55 | - $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id; |
|
56 | - $head[$tab][1] = $langs->trans("Documents"); |
|
57 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
58 | - $head[$tab][2] = 'documents'; |
|
59 | - $tab++; |
|
55 | + $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id; |
|
56 | + $head[$tab][1] = $langs->trans("Documents"); |
|
57 | + if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
58 | + $head[$tab][2] = 'documents'; |
|
59 | + $tab++; |
|
60 | 60 | |
61 | 61 | $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id; |
62 | 62 | $head[$tab][1] = $langs->trans("Info"); |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function donation_admin_prepare_head() |
30 | 30 | { |
31 | - global $langs, $conf; |
|
31 | + global $langs, $conf; |
|
32 | 32 | |
33 | - $h = 0; |
|
34 | - $head = array(); |
|
33 | + $h = 0; |
|
34 | + $head = array(); |
|
35 | 35 | |
36 | - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; |
|
37 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
38 | - $head[$h][2] = 'general'; |
|
39 | - $h ++; |
|
36 | + $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; |
|
37 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
38 | + $head[$h][2] = 'general'; |
|
39 | + $h ++; |
|
40 | 40 | |
41 | - // Show more tabs from modules |
|
42 | - // Entries must be declared in modules descriptor with line |
|
43 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
44 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
45 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin'); |
|
41 | + // Show more tabs from modules |
|
42 | + // Entries must be declared in modules descriptor with line |
|
43 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
44 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
45 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin'); |
|
46 | 46 | |
47 | - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; |
|
48 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
47 | + $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; |
|
48 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
49 | 49 | $head[$h][2] = 'attributes'; |
50 | - $h++; |
|
50 | + $h++; |
|
51 | 51 | |
52 | - complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove'); |
|
52 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove'); |
|
53 | 53 | |
54 | - return $head; |
|
54 | + return $head; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -62,48 +62,48 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function donation_prepare_head($object) |
64 | 64 | { |
65 | - global $db, $langs, $conf; |
|
65 | + global $db, $langs, $conf; |
|
66 | 66 | |
67 | - $h = 0; |
|
68 | - $head = array(); |
|
67 | + $h = 0; |
|
68 | + $head = array(); |
|
69 | 69 | |
70 | - $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; |
|
71 | - $head[$h][1] = $langs->trans("Card"); |
|
72 | - $head[$h][2] = 'card'; |
|
73 | - $h ++; |
|
70 | + $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; |
|
71 | + $head[$h][1] = $langs->trans("Card"); |
|
72 | + $head[$h][2] = 'card'; |
|
73 | + $h ++; |
|
74 | 74 | |
75 | - // Show more tabs from modules |
|
76 | - // Entries must be declared in modules descriptor with line |
|
77 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
78 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
79 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation'); |
|
75 | + // Show more tabs from modules |
|
76 | + // Entries must be declared in modules descriptor with line |
|
77 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
78 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
79 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation'); |
|
80 | 80 | |
81 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
81 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
82 | 82 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
83 | - $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); |
|
84 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
83 | + $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); |
|
84 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
85 | 85 | $nbLinks=Link::count($db, $object->element, $object->id); |
86 | - $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; |
|
87 | - $head[$h][1] = $langs->trans('Documents'); |
|
88 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
89 | - $head[$h][2] = 'documents'; |
|
90 | - $h++; |
|
86 | + $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; |
|
87 | + $head[$h][1] = $langs->trans('Documents'); |
|
88 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
89 | + $head[$h][2] = 'documents'; |
|
90 | + $h++; |
|
91 | 91 | |
92 | - $nbNote = 0; |
|
93 | - if(!empty($object->note_private)) $nbNote++; |
|
94 | - if(!empty($object->note_public)) $nbNote++; |
|
95 | - $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id; |
|
96 | - $head[$h][1] = $langs->trans("Notes"); |
|
97 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | - $head[$h][2] = 'note'; |
|
99 | - $h++; |
|
92 | + $nbNote = 0; |
|
93 | + if(!empty($object->note_private)) $nbNote++; |
|
94 | + if(!empty($object->note_public)) $nbNote++; |
|
95 | + $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id; |
|
96 | + $head[$h][1] = $langs->trans("Notes"); |
|
97 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | + $head[$h][2] = 'note'; |
|
99 | + $h++; |
|
100 | 100 | |
101 | - $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; |
|
102 | - $head[$h][1] = $langs->trans("Info"); |
|
103 | - $head[$h][2] = 'info'; |
|
104 | - $h++; |
|
101 | + $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; |
|
102 | + $head[$h][1] = $langs->trans("Info"); |
|
103 | + $head[$h][2] = 'info'; |
|
104 | + $h++; |
|
105 | 105 | |
106 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove'); |
|
106 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove'); |
|
107 | 107 | |
108 | - return $head; |
|
108 | + return $head; |
|
109 | 109 | } |
@@ -29,33 +29,33 @@ |
||
29 | 29 | */ |
30 | 30 | function trip_prepare_head(Deplacement $object) |
31 | 31 | { |
32 | - global $langs, $conf; |
|
32 | + global $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/card.php?id=' . $object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/card.php?id=' . $object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - // Show more tabs from modules |
|
43 | - // Entries must be declared in modules descriptor with line |
|
42 | + // Show more tabs from modules |
|
43 | + // Entries must be declared in modules descriptor with line |
|
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'trip'); |
|
46 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip'); |
|
47 | 47 | |
48 | - $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id; |
|
49 | - $head[$h][1] = $langs->trans("Documents"); |
|
50 | - $head[$h][2] = 'documents'; |
|
51 | - $h++; |
|
48 | + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id; |
|
49 | + $head[$h][1] = $langs->trans("Documents"); |
|
50 | + $head[$h][2] = 'documents'; |
|
51 | + $h++; |
|
52 | 52 | |
53 | - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; |
|
54 | - $head[$h][1] = $langs->trans("Info"); |
|
55 | - $head[$h][2] = 'info'; |
|
56 | - $h++; |
|
53 | + $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; |
|
54 | + $head[$h][1] = $langs->trans("Info"); |
|
55 | + $head[$h][2] = 'info'; |
|
56 | + $h++; |
|
57 | 57 | |
58 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); |
|
58 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); |
|
59 | 59 | |
60 | - return $head; |
|
60 | + return $head; |
|
61 | 61 | } |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function categories_prepare_head($object,$type) |
33 | 33 | { |
34 | - global $langs, $conf, $user; |
|
34 | + global $langs, $conf, $user; |
|
35 | 35 | |
36 | - // Load translation files required by the page |
|
36 | + // Load translation files required by the page |
|
37 | 37 | $langs->loadLangs(array('categories', 'products')); |
38 | 38 | |
39 | - $h = 0; |
|
40 | - $head = array(); |
|
39 | + $h = 0; |
|
40 | + $head = array(); |
|
41 | 41 | |
42 | - $head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type; |
|
43 | - $head[$h][1] = $langs->trans("Card"); |
|
44 | - $head[$h][2] = 'card'; |
|
45 | - $h++; |
|
42 | + $head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type; |
|
43 | + $head[$h][1] = $langs->trans("Card"); |
|
44 | + $head[$h][2] = 'card'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - $head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&type='.$type; |
|
48 | - $head[$h][1] = $langs->trans("Photos"); |
|
49 | - $head[$h][2] = 'photos'; |
|
50 | - $h++; |
|
47 | + $head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&type='.$type; |
|
48 | + $head[$h][1] = $langs->trans("Photos"); |
|
49 | + $head[$h][2] = 'photos'; |
|
50 | + $h++; |
|
51 | 51 | |
52 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
53 | - { |
|
54 | - $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type; |
|
55 | - $head[$h][1] = $langs->trans("Translation"); |
|
56 | - $head[$h][2] = 'translation'; |
|
57 | - $h++; |
|
58 | - } |
|
52 | + if (! empty($conf->global->MAIN_MULTILANGS)) |
|
53 | + { |
|
54 | + $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type; |
|
55 | + $head[$h][1] = $langs->trans("Translation"); |
|
56 | + $head[$h][2] = 'translation'; |
|
57 | + $h++; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | // Show more tabs from modules |
61 | 61 | // Entries must be declared in modules descriptor with line |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type,'remove'); |
67 | 67 | |
68 | - return $head; |
|
68 | + return $head; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function categoriesadmin_prepare_head() |
78 | 78 | { |
79 | - global $langs, $conf, $user; |
|
79 | + global $langs, $conf, $user; |
|
80 | 80 | |
81 | - $langs->load("categories"); |
|
81 | + $langs->load("categories"); |
|
82 | 82 | |
83 | - $h = 0; |
|
84 | - $head = array(); |
|
83 | + $h = 0; |
|
84 | + $head = array(); |
|
85 | 85 | |
86 | - $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie.php'; |
|
87 | - $head[$h][1] = $langs->trans("Setup"); |
|
88 | - $head[$h][2] = 'setup'; |
|
89 | - $h++; |
|
86 | + $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie.php'; |
|
87 | + $head[$h][1] = $langs->trans("Setup"); |
|
88 | + $head[$h][2] = 'setup'; |
|
89 | + $h++; |
|
90 | 90 | |
91 | - $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php'; |
|
92 | - $head[$h][1] = $langs->trans("ExtraFieldsCategories"); |
|
93 | - $head[$h][2] = 'attributes_categories'; |
|
94 | - $h++; |
|
91 | + $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php'; |
|
92 | + $head[$h][1] = $langs->trans("ExtraFieldsCategories"); |
|
93 | + $head[$h][2] = 'attributes_categories'; |
|
94 | + $h++; |
|
95 | 95 | |
96 | - // Show more tabs from modules |
|
97 | - // Entries must be declared in modules descriptor with line |
|
98 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
99 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
100 | - complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin'); |
|
96 | + // Show more tabs from modules |
|
97 | + // Entries must be declared in modules descriptor with line |
|
98 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
99 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
100 | + complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin'); |
|
101 | 101 | |
102 | - complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin','remove'); |
|
102 | + complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin','remove'); |
|
103 | 103 | |
104 | - return $head; |
|
104 | + return $head; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 |
@@ -35,122 +35,122 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function project_prepare_head($object) |
37 | 37 | { |
38 | - global $db, $langs, $conf, $user; |
|
39 | - |
|
40 | - $h = 0; |
|
41 | - $head = array(); |
|
42 | - |
|
43 | - $head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.$object->id; |
|
44 | - $head[$h][1] = $langs->trans("Project"); |
|
45 | - $head[$h][2] = 'project'; |
|
46 | - $h++; |
|
47 | - |
|
48 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
49 | - $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; |
|
50 | - $head[$h][1] = $langs->trans("ProjectContact"); |
|
51 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | - $head[$h][2] = 'contact'; |
|
53 | - $h++; |
|
54 | - |
|
55 | - if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
56 | - { |
|
57 | - // Then tab for sub level of projet, i mean tasks |
|
58 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; |
|
59 | - $head[$h][1] = $langs->trans("Tasks"); |
|
60 | - |
|
61 | - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
62 | - $taskstatic=new Task($db); |
|
63 | - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
64 | - if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
65 | - $head[$h][2] = 'tasks'; |
|
66 | - $h++; |
|
67 | - |
|
68 | - $nbTimeSpent=0; |
|
69 | - $sql = "SELECT t.rowid"; |
|
70 | - //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
|
71 | - //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
|
72 | - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
73 | - $sql .= " WHERE t.fk_task = pt.rowid"; |
|
74 | - $sql .= " AND pt.fk_projet =".$object->id; |
|
75 | - $resql = $db->query($sql); |
|
76 | - if ($resql) |
|
77 | - { |
|
78 | - $obj = $db->fetch_object($resql); |
|
79 | - if ($obj) $nbTimeSpent=1; |
|
80 | - } |
|
81 | - else dol_print_error($db); |
|
82 | - |
|
83 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; |
|
84 | - $head[$h][1] = $langs->trans("TimeSpent"); |
|
85 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
86 | - $head[$h][2] = 'timespent'; |
|
87 | - $h++; |
|
88 | - } |
|
89 | - |
|
90 | - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) |
|
91 | - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) |
|
92 | - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) |
|
93 | - { |
|
94 | - $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; |
|
95 | - $head[$h][1] = $langs->trans("ProjectOverview"); |
|
96 | - $head[$h][2] = 'element'; |
|
97 | - $h++; |
|
98 | - } |
|
99 | - |
|
100 | - // Show more tabs from modules |
|
101 | - // Entries must be declared in modules descriptor with line |
|
102 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
103 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
104 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); |
|
105 | - |
|
106 | - |
|
107 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
108 | - { |
|
109 | - $nbNote = 0; |
|
110 | - if(!empty($object->note_private)) $nbNote++; |
|
111 | - if(!empty($object->note_public)) $nbNote++; |
|
112 | - $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; |
|
113 | - $head[$h][1] = $langs->trans('Notes'); |
|
114 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
115 | - $head[$h][2] = 'notes'; |
|
116 | - $h++; |
|
117 | - } |
|
118 | - |
|
119 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
120 | - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
121 | - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
122 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
123 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
124 | - $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; |
|
125 | - $head[$h][1] = $langs->trans('Documents'); |
|
126 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
127 | - $head[$h][2] = 'document'; |
|
128 | - $h++; |
|
129 | - |
|
130 | - // Manage discussion |
|
131 | - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) |
|
132 | - { |
|
133 | - $nbComments = $object->getNbComments(); |
|
134 | - $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; |
|
135 | - $head[$h][1] = $langs->trans("CommentLink"); |
|
136 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
137 | - $head[$h][2] = 'project_comment'; |
|
138 | - $h++; |
|
139 | - } |
|
140 | - |
|
141 | - $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; |
|
142 | - $head[$h][1].= $langs->trans("Events"); |
|
143 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
144 | - { |
|
145 | - $head[$h][1].= '/'; |
|
146 | - $head[$h][1].= $langs->trans("Agenda"); |
|
147 | - } |
|
148 | - $head[$h][2] = 'agenda'; |
|
149 | - $h++; |
|
150 | - |
|
151 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); |
|
152 | - |
|
153 | - return $head; |
|
38 | + global $db, $langs, $conf, $user; |
|
39 | + |
|
40 | + $h = 0; |
|
41 | + $head = array(); |
|
42 | + |
|
43 | + $head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.$object->id; |
|
44 | + $head[$h][1] = $langs->trans("Project"); |
|
45 | + $head[$h][2] = 'project'; |
|
46 | + $h++; |
|
47 | + |
|
48 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
49 | + $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; |
|
50 | + $head[$h][1] = $langs->trans("ProjectContact"); |
|
51 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | + $head[$h][2] = 'contact'; |
|
53 | + $h++; |
|
54 | + |
|
55 | + if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
56 | + { |
|
57 | + // Then tab for sub level of projet, i mean tasks |
|
58 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; |
|
59 | + $head[$h][1] = $langs->trans("Tasks"); |
|
60 | + |
|
61 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
62 | + $taskstatic=new Task($db); |
|
63 | + $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
64 | + if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
65 | + $head[$h][2] = 'tasks'; |
|
66 | + $h++; |
|
67 | + |
|
68 | + $nbTimeSpent=0; |
|
69 | + $sql = "SELECT t.rowid"; |
|
70 | + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
|
71 | + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
|
72 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
73 | + $sql .= " WHERE t.fk_task = pt.rowid"; |
|
74 | + $sql .= " AND pt.fk_projet =".$object->id; |
|
75 | + $resql = $db->query($sql); |
|
76 | + if ($resql) |
|
77 | + { |
|
78 | + $obj = $db->fetch_object($resql); |
|
79 | + if ($obj) $nbTimeSpent=1; |
|
80 | + } |
|
81 | + else dol_print_error($db); |
|
82 | + |
|
83 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; |
|
84 | + $head[$h][1] = $langs->trans("TimeSpent"); |
|
85 | + if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
86 | + $head[$h][2] = 'timespent'; |
|
87 | + $h++; |
|
88 | + } |
|
89 | + |
|
90 | + if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) |
|
91 | + || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) |
|
92 | + || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) |
|
93 | + { |
|
94 | + $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; |
|
95 | + $head[$h][1] = $langs->trans("ProjectOverview"); |
|
96 | + $head[$h][2] = 'element'; |
|
97 | + $h++; |
|
98 | + } |
|
99 | + |
|
100 | + // Show more tabs from modules |
|
101 | + // Entries must be declared in modules descriptor with line |
|
102 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
103 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
104 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); |
|
105 | + |
|
106 | + |
|
107 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
108 | + { |
|
109 | + $nbNote = 0; |
|
110 | + if(!empty($object->note_private)) $nbNote++; |
|
111 | + if(!empty($object->note_public)) $nbNote++; |
|
112 | + $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; |
|
113 | + $head[$h][1] = $langs->trans('Notes'); |
|
114 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
115 | + $head[$h][2] = 'notes'; |
|
116 | + $h++; |
|
117 | + } |
|
118 | + |
|
119 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
120 | + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
121 | + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
122 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
123 | + $nbLinks=Link::count($db, $object->element, $object->id); |
|
124 | + $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; |
|
125 | + $head[$h][1] = $langs->trans('Documents'); |
|
126 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
127 | + $head[$h][2] = 'document'; |
|
128 | + $h++; |
|
129 | + |
|
130 | + // Manage discussion |
|
131 | + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) |
|
132 | + { |
|
133 | + $nbComments = $object->getNbComments(); |
|
134 | + $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; |
|
135 | + $head[$h][1] = $langs->trans("CommentLink"); |
|
136 | + if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
137 | + $head[$h][2] = 'project_comment'; |
|
138 | + $h++; |
|
139 | + } |
|
140 | + |
|
141 | + $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; |
|
142 | + $head[$h][1].= $langs->trans("Events"); |
|
143 | + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
144 | + { |
|
145 | + $head[$h][1].= '/'; |
|
146 | + $head[$h][1].= $langs->trans("Agenda"); |
|
147 | + } |
|
148 | + $head[$h][2] = 'agenda'; |
|
149 | + $h++; |
|
150 | + |
|
151 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); |
|
152 | + |
|
153 | + return $head; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,86 +162,86 @@ discard block |
||
162 | 162 | */ |
163 | 163 | function task_prepare_head($object) |
164 | 164 | { |
165 | - global $db, $langs, $conf, $user; |
|
166 | - $h = 0; |
|
167 | - $head = array(); |
|
168 | - |
|
169 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
170 | - $head[$h][1] = $langs->trans("Card"); |
|
171 | - $head[$h][2] = 'task_task'; |
|
172 | - $h++; |
|
173 | - |
|
174 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
175 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
176 | - $head[$h][1] = $langs->trans("TaskRessourceLinks"); |
|
177 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
178 | - $head[$h][2] = 'task_contact'; |
|
179 | - $h++; |
|
180 | - |
|
181 | - // Is there timespent ? |
|
182 | - $nbTimeSpent=0; |
|
183 | - $sql = "SELECT t.rowid"; |
|
184 | - //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
|
185 | - //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
|
186 | - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; |
|
187 | - $sql .= " WHERE t.fk_task =".$object->id; |
|
188 | - $resql = $db->query($sql); |
|
189 | - if ($resql) |
|
190 | - { |
|
191 | - $obj = $db->fetch_object($resql); |
|
192 | - if ($obj) $nbTimeSpent=1; |
|
193 | - } |
|
194 | - else dol_print_error($db); |
|
195 | - |
|
196 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
197 | - $head[$h][1] = $langs->trans("TimeSpent"); |
|
198 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
199 | - $head[$h][2] = 'task_time'; |
|
200 | - $h++; |
|
201 | - |
|
202 | - // Show more tabs from modules |
|
203 | - // Entries must be declared in modules descriptor with line |
|
204 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
205 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
206 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); |
|
207 | - |
|
208 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
209 | - { |
|
210 | - $nbNote = 0; |
|
211 | - if(!empty($object->note_private)) $nbNote++; |
|
212 | - if(!empty($object->note_public)) $nbNote++; |
|
213 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
214 | - $head[$h][1] = $langs->trans('Notes'); |
|
215 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
216 | - $head[$h][2] = 'task_notes'; |
|
217 | - $h++; |
|
218 | - } |
|
219 | - |
|
220 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
221 | - $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); |
|
222 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
223 | - include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
224 | - $nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
225 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
226 | - $head[$h][1] = $langs->trans('Documents'); |
|
227 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
228 | - $head[$h][2] = 'task_document'; |
|
229 | - $h++; |
|
230 | - |
|
231 | - // Manage discussion |
|
232 | - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) |
|
233 | - { |
|
234 | - $nbComments = $object->getNbComments(); |
|
235 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
236 | - $head[$h][1] = $langs->trans("CommentLink"); |
|
237 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
238 | - $head[$h][2] = 'task_comment'; |
|
239 | - $h++; |
|
240 | - } |
|
241 | - |
|
242 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); |
|
243 | - |
|
244 | - return $head; |
|
165 | + global $db, $langs, $conf, $user; |
|
166 | + $h = 0; |
|
167 | + $head = array(); |
|
168 | + |
|
169 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
170 | + $head[$h][1] = $langs->trans("Card"); |
|
171 | + $head[$h][2] = 'task_task'; |
|
172 | + $h++; |
|
173 | + |
|
174 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
175 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
176 | + $head[$h][1] = $langs->trans("TaskRessourceLinks"); |
|
177 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
178 | + $head[$h][2] = 'task_contact'; |
|
179 | + $h++; |
|
180 | + |
|
181 | + // Is there timespent ? |
|
182 | + $nbTimeSpent=0; |
|
183 | + $sql = "SELECT t.rowid"; |
|
184 | + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
|
185 | + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
|
186 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; |
|
187 | + $sql .= " WHERE t.fk_task =".$object->id; |
|
188 | + $resql = $db->query($sql); |
|
189 | + if ($resql) |
|
190 | + { |
|
191 | + $obj = $db->fetch_object($resql); |
|
192 | + if ($obj) $nbTimeSpent=1; |
|
193 | + } |
|
194 | + else dol_print_error($db); |
|
195 | + |
|
196 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
197 | + $head[$h][1] = $langs->trans("TimeSpent"); |
|
198 | + if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
199 | + $head[$h][2] = 'task_time'; |
|
200 | + $h++; |
|
201 | + |
|
202 | + // Show more tabs from modules |
|
203 | + // Entries must be declared in modules descriptor with line |
|
204 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
205 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
206 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); |
|
207 | + |
|
208 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
209 | + { |
|
210 | + $nbNote = 0; |
|
211 | + if(!empty($object->note_private)) $nbNote++; |
|
212 | + if(!empty($object->note_public)) $nbNote++; |
|
213 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
214 | + $head[$h][1] = $langs->trans('Notes'); |
|
215 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
216 | + $head[$h][2] = 'task_notes'; |
|
217 | + $h++; |
|
218 | + } |
|
219 | + |
|
220 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
221 | + $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); |
|
222 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
223 | + include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
224 | + $nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
225 | + $nbLinks=Link::count($db, $object->element, $object->id); |
|
226 | + $head[$h][1] = $langs->trans('Documents'); |
|
227 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
228 | + $head[$h][2] = 'task_document'; |
|
229 | + $h++; |
|
230 | + |
|
231 | + // Manage discussion |
|
232 | + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) |
|
233 | + { |
|
234 | + $nbComments = $object->getNbComments(); |
|
235 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
236 | + $head[$h][1] = $langs->trans("CommentLink"); |
|
237 | + if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
238 | + $head[$h][2] = 'task_comment'; |
|
239 | + $h++; |
|
240 | + } |
|
241 | + |
|
242 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); |
|
243 | + |
|
244 | + return $head; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,33 +253,33 @@ discard block |
||
253 | 253 | */ |
254 | 254 | function project_timesheet_prepare_head($mode, $fuser=null) |
255 | 255 | { |
256 | - global $langs, $conf, $user; |
|
257 | - $h = 0; |
|
258 | - $head = array(); |
|
259 | - |
|
260 | - $h = 0; |
|
261 | - |
|
262 | - $param=''; |
|
263 | - $param.=($mode?'&mode='.$mode:''); |
|
264 | - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; |
|
265 | - |
|
266 | - if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) |
|
267 | - { |
|
268 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); |
|
269 | - $head[$h][1] = $langs->trans("InputPerWeek"); |
|
270 | - $head[$h][2] = 'inputperweek'; |
|
271 | - $h++; |
|
272 | - } |
|
273 | - |
|
274 | - if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) |
|
275 | - { |
|
276 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); |
|
277 | - $head[$h][1] = $langs->trans("InputPerDay"); |
|
278 | - $head[$h][2] = 'inputperday'; |
|
279 | - $h++; |
|
280 | - } |
|
281 | - |
|
282 | - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
|
256 | + global $langs, $conf, $user; |
|
257 | + $h = 0; |
|
258 | + $head = array(); |
|
259 | + |
|
260 | + $h = 0; |
|
261 | + |
|
262 | + $param=''; |
|
263 | + $param.=($mode?'&mode='.$mode:''); |
|
264 | + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; |
|
265 | + |
|
266 | + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) |
|
267 | + { |
|
268 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); |
|
269 | + $head[$h][1] = $langs->trans("InputPerWeek"); |
|
270 | + $head[$h][2] = 'inputperweek'; |
|
271 | + $h++; |
|
272 | + } |
|
273 | + |
|
274 | + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) |
|
275 | + { |
|
276 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); |
|
277 | + $head[$h][1] = $langs->trans("InputPerDay"); |
|
278 | + $head[$h][2] = 'inputperday'; |
|
279 | + $h++; |
|
280 | + } |
|
281 | + |
|
282 | + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
|
283 | 283 | { |
284 | 284 | $head[$h][0] = DOL_URL_ROOT."/projet/activity/perline.php".($param?'?'.$param:''); |
285 | 285 | $head[$h][1] = $langs->trans("InputDetail"); |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | $h++; |
288 | 288 | }*/ |
289 | 289 | |
290 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet'); |
|
290 | + complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet'); |
|
291 | 291 | |
292 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove'); |
|
292 | + complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove'); |
|
293 | 293 | |
294 | - return $head; |
|
294 | + return $head; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -302,32 +302,32 @@ discard block |
||
302 | 302 | */ |
303 | 303 | function project_admin_prepare_head() |
304 | 304 | { |
305 | - global $langs, $conf, $user; |
|
306 | - $h = 0; |
|
307 | - $head = array(); |
|
305 | + global $langs, $conf, $user; |
|
306 | + $h = 0; |
|
307 | + $head = array(); |
|
308 | 308 | |
309 | - $h = 0; |
|
309 | + $h = 0; |
|
310 | 310 | |
311 | - $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php"; |
|
312 | - $head[$h][1] = $langs->trans("Projects"); |
|
313 | - $head[$h][2] = 'project'; |
|
314 | - $h++; |
|
311 | + $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php"; |
|
312 | + $head[$h][1] = $langs->trans("Projects"); |
|
313 | + $head[$h][2] = 'project'; |
|
314 | + $h++; |
|
315 | 315 | |
316 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin'); |
|
316 | + complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin'); |
|
317 | 317 | |
318 | - $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php"; |
|
319 | - $head[$h][1] = $langs->trans("ExtraFieldsProject"); |
|
320 | - $head[$h][2] = 'attributes'; |
|
321 | - $h++; |
|
318 | + $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php"; |
|
319 | + $head[$h][1] = $langs->trans("ExtraFieldsProject"); |
|
320 | + $head[$h][2] = 'attributes'; |
|
321 | + $h++; |
|
322 | 322 | |
323 | - $head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php'; |
|
324 | - $head[$h][1] = $langs->trans("ExtraFieldsProjectTask"); |
|
325 | - $head[$h][2] = 'attributes_task'; |
|
326 | - $h++; |
|
323 | + $head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php'; |
|
324 | + $head[$h][1] = $langs->trans("ExtraFieldsProjectTask"); |
|
325 | + $head[$h][2] = 'attributes_task'; |
|
326 | + $h++; |
|
327 | 327 | |
328 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove'); |
|
328 | + complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove'); |
|
329 | 329 | |
330 | - return $head; |
|
330 | + return $head; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
@@ -349,284 +349,284 @@ discard block |
||
349 | 349 | */ |
350 | 350 | function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0, $filterprogresscalc='') |
351 | 351 | { |
352 | - global $user, $bc, $langs, $conf, $db; |
|
353 | - global $projectstatic, $taskstatic; |
|
354 | - |
|
355 | - $lastprojectid=0; |
|
356 | - |
|
357 | - $projectsArrayId=explode(',',$projectsListId); |
|
358 | - if ($filterprogresscalc!=='') { |
|
359 | - foreach ($lines as $key=>$line) { |
|
360 | - if (!empty($line->planned_workload) && !empty($line->duration)) { |
|
361 | - $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); |
|
362 | - if (!eval($filterprogresscalc)) { |
|
363 | - unset($lines[$key]); |
|
364 | - } |
|
365 | - } |
|
366 | - } |
|
367 | - $lines=array_values($lines); |
|
368 | - } |
|
369 | - |
|
370 | - $numlines=count($lines); |
|
371 | - |
|
372 | - // We declare counter as global because we want to edit them into recursive call |
|
373 | - global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned; |
|
374 | - if ($level == 0) |
|
375 | - { |
|
376 | - $total_projectlinesa_spent=0; |
|
377 | - $total_projectlinesa_planned=0; |
|
378 | - $total_projectlinesa_spent_if_planned=0; |
|
379 | - } |
|
380 | - |
|
381 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
382 | - { |
|
383 | - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
384 | - |
|
385 | - // Process line |
|
386 | - // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; |
|
387 | - |
|
388 | - if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
389 | - { |
|
390 | - // Show task line. |
|
391 | - $showline=1; |
|
392 | - $showlineingray=0; |
|
393 | - |
|
394 | - // If there is filters to use |
|
395 | - if (is_array($taskrole)) |
|
396 | - { |
|
397 | - // If task not legitimate to show, search if a legitimate task exists later in tree |
|
398 | - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
399 | - { |
|
400 | - // So search if task has a subtask legitimate to show |
|
401 | - $foundtaskforuserdeeper=0; |
|
402 | - searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); |
|
403 | - //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>'; |
|
404 | - if ($foundtaskforuserdeeper > 0) |
|
405 | - { |
|
406 | - $showlineingray=1; // We will show line but in gray |
|
407 | - } |
|
408 | - else |
|
409 | - { |
|
410 | - $showline=0; // No reason to show line |
|
411 | - } |
|
412 | - } |
|
413 | - } |
|
414 | - else |
|
415 | - { |
|
416 | - // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project |
|
417 | - // or into all other projects if user has permission to). |
|
418 | - if (empty($user->rights->projet->all->lire)) |
|
419 | - { |
|
420 | - // User is not allowed on this project and project is not public, so we hide line |
|
421 | - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
422 | - { |
|
423 | - // Note that having a user assigned to a task into a project user has no permission on, should not be possible |
|
424 | - // because assignement on task can be done only on contact of project. |
|
425 | - // If assignement was done and after, was removed from contact of project, then we can hide the line. |
|
426 | - $showline=0; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - |
|
431 | - if ($showline) |
|
432 | - { |
|
433 | - // Break on a new project |
|
434 | - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
435 | - { |
|
436 | - $var = !$var; |
|
437 | - $lastprojectid=$lines[$i]->fk_project; |
|
438 | - } |
|
439 | - |
|
440 | - print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; |
|
441 | - |
|
442 | - if ($showproject) |
|
443 | - { |
|
444 | - // Project ref |
|
445 | - print "<td>"; |
|
446 | - //if ($showlineingray) print '<i>'; |
|
447 | - $projectstatic->id=$lines[$i]->fk_project; |
|
448 | - $projectstatic->ref=$lines[$i]->projectref; |
|
449 | - $projectstatic->public=$lines[$i]->public; |
|
450 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
451 | - if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
452 | - else print $projectstatic->getNomUrl(1,'nolink'); |
|
453 | - //if ($showlineingray) print '</i>'; |
|
454 | - print "</td>"; |
|
455 | - |
|
456 | - // Project status |
|
457 | - print '<td>'; |
|
458 | - $projectstatic->statut=$lines[$i]->projectstatus; |
|
459 | - print $projectstatic->getLibStatut(2); |
|
460 | - print "</td>"; |
|
461 | - } |
|
462 | - |
|
463 | - // Ref of task |
|
464 | - print '<td>'; |
|
465 | - if ($showlineingray) |
|
466 | - { |
|
467 | - print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>'; |
|
468 | - } |
|
469 | - else |
|
470 | - { |
|
471 | - $taskstatic->id=$lines[$i]->id; |
|
472 | - $taskstatic->ref=$lines[$i]->ref; |
|
473 | - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); |
|
474 | - print $taskstatic->getNomUrl(1,'withproject'); |
|
475 | - } |
|
476 | - print '</td>'; |
|
477 | - |
|
478 | - // Title of task |
|
479 | - print "<td>"; |
|
480 | - if ($showlineingray) print '<i>'; |
|
481 | - //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">'; |
|
482 | - for ($k = 0 ; $k < $level ; $k++) |
|
483 | - { |
|
484 | - print " "; |
|
485 | - } |
|
486 | - print $lines[$i]->label; |
|
487 | - if ($showlineingray) print '</i>'; |
|
488 | - //else print '</a>'; |
|
489 | - print "</td>\n"; |
|
490 | - |
|
491 | - // Date start |
|
492 | - print '<td align="center">'; |
|
493 | - print dol_print_date($lines[$i]->date_start,'dayhour'); |
|
494 | - print '</td>'; |
|
495 | - |
|
496 | - // Date end |
|
497 | - print '<td align="center">'; |
|
498 | - $taskstatic->projectstatus = $lines[$i]->projectstatus; |
|
499 | - $taskstatic->progress = $lines[$i]->progress; |
|
500 | - $taskstatic->fk_statut = $lines[$i]->status; |
|
501 | - $taskstatic->datee = $lines[$i]->date_end; |
|
502 | - print dol_print_date($lines[$i]->date_end,'dayhour'); |
|
503 | - if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); |
|
504 | - print '</td>'; |
|
505 | - |
|
506 | - $plannedworkloadoutputformat='allhourmin'; |
|
507 | - $timespentoutputformat='allhourmin'; |
|
508 | - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
509 | - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
510 | - |
|
511 | - // Planned Workload (in working hours) |
|
512 | - print '<td align="right">'; |
|
513 | - $fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat); |
|
514 | - $workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks |
|
515 | - if ($lines[$i]->planned_workload != '') |
|
516 | - { |
|
517 | - print $fullhour; |
|
518 | - // TODO Add delay taking account of working hours per day and working day per week |
|
519 | - //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')'; |
|
520 | - } |
|
521 | - //else print '--:--'; |
|
522 | - print '</td>'; |
|
523 | - |
|
524 | - // Time spent |
|
525 | - print '<td align="right">'; |
|
526 | - if ($showlineingray) print '<i>'; |
|
527 | - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
528 | - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
529 | - else print '--:--'; |
|
530 | - if ($showlineingray) print '</i>'; |
|
531 | - else print '</a>'; |
|
532 | - print '</td>'; |
|
533 | - |
|
534 | - // Progress calculated (Note: ->duration is time spent) |
|
535 | - print '<td align="right">'; |
|
536 | - if ($lines[$i]->planned_workload || $lines[$i]->duration) |
|
537 | - { |
|
538 | - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
539 | - else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
|
540 | - } |
|
541 | - print '</td>'; |
|
542 | - |
|
543 | - // Progress declared |
|
544 | - print '<td align="right">'; |
|
545 | - if ($lines[$i]->progress != '') |
|
546 | - { |
|
547 | - print $lines[$i]->progress.' %'; |
|
548 | - } |
|
549 | - print '</td>'; |
|
550 | - |
|
551 | - // Contacts of task |
|
552 | - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
553 | - { |
|
554 | - print '<td>'; |
|
555 | - foreach(array('internal','external') as $source) |
|
556 | - { |
|
557 | - $tab = $lines[$i]->liste_contact(-1,$source); |
|
558 | - $num=count($tab); |
|
559 | - if (!empty($num)){ |
|
560 | - foreach ($tab as $contacttask){ |
|
561 | - //var_dump($contacttask); |
|
562 | - if ($source == 'internal') $c = new User($db); |
|
563 | - else $c = new Contact($db); |
|
564 | - $c->fetch($contacttask['id']); |
|
565 | - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '<br>'; |
|
566 | - } |
|
567 | - } |
|
568 | - } |
|
569 | - print '</td>'; |
|
570 | - } |
|
571 | - |
|
572 | - // Tick to drag and drop |
|
573 | - if ($addordertick) |
|
574 | - { |
|
575 | - print '<td align="center" class="tdlineupdown hideonsmartphone"> </td>'; |
|
576 | - } |
|
577 | - |
|
578 | - print "</tr>\n"; |
|
579 | - |
|
580 | - if (! $showlineingray) $inc++; |
|
581 | - |
|
582 | - if ($level >= 0) // Call sublevels |
|
583 | - { |
|
584 | - $level++; |
|
585 | - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); |
|
586 | - $level--; |
|
587 | - } |
|
588 | - |
|
589 | - $total_projectlinesa_spent += $lines[$i]->duration; |
|
590 | - $total_projectlinesa_planned += $lines[$i]->planned_workload; |
|
591 | - if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; |
|
592 | - } |
|
593 | - } |
|
594 | - else |
|
595 | - { |
|
596 | - //$level--; |
|
597 | - } |
|
598 | - } |
|
599 | - |
|
600 | - if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level <= 0) |
|
601 | - { |
|
602 | - print '<tr class="liste_total nodrag nodrop">'; |
|
603 | - print '<td class="liste_total">'.$langs->trans("Total").'</td>'; |
|
604 | - if ($showproject) print '<td></td><td></td>'; |
|
605 | - print '<td></td>'; |
|
606 | - print '<td></td>'; |
|
607 | - print '<td></td>'; |
|
608 | - print '<td align="right" class="nowrap liste_total">'; |
|
609 | - print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); |
|
610 | - print '</td>'; |
|
611 | - print '<td align="right" class="nowrap liste_total">'; |
|
612 | - if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
613 | - print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); |
|
614 | - if ($projectidfortotallink > 0) print '</a>'; |
|
615 | - print '</td>'; |
|
616 | - print '<td align="right" class="nowrap liste_total">'; |
|
617 | - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
618 | - print '</td>'; |
|
619 | - print '<td></td>'; |
|
620 | - // Contacts of task |
|
621 | - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
622 | - { |
|
623 | - print '<td></td>'; |
|
624 | - } |
|
625 | - if ($addordertick) print '<td class="hideonsmartphone"></td>'; |
|
626 | - print '</tr>'; |
|
627 | - } |
|
628 | - |
|
629 | - return $inc; |
|
352 | + global $user, $bc, $langs, $conf, $db; |
|
353 | + global $projectstatic, $taskstatic; |
|
354 | + |
|
355 | + $lastprojectid=0; |
|
356 | + |
|
357 | + $projectsArrayId=explode(',',$projectsListId); |
|
358 | + if ($filterprogresscalc!=='') { |
|
359 | + foreach ($lines as $key=>$line) { |
|
360 | + if (!empty($line->planned_workload) && !empty($line->duration)) { |
|
361 | + $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); |
|
362 | + if (!eval($filterprogresscalc)) { |
|
363 | + unset($lines[$key]); |
|
364 | + } |
|
365 | + } |
|
366 | + } |
|
367 | + $lines=array_values($lines); |
|
368 | + } |
|
369 | + |
|
370 | + $numlines=count($lines); |
|
371 | + |
|
372 | + // We declare counter as global because we want to edit them into recursive call |
|
373 | + global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned; |
|
374 | + if ($level == 0) |
|
375 | + { |
|
376 | + $total_projectlinesa_spent=0; |
|
377 | + $total_projectlinesa_planned=0; |
|
378 | + $total_projectlinesa_spent_if_planned=0; |
|
379 | + } |
|
380 | + |
|
381 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
382 | + { |
|
383 | + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
384 | + |
|
385 | + // Process line |
|
386 | + // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; |
|
387 | + |
|
388 | + if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
389 | + { |
|
390 | + // Show task line. |
|
391 | + $showline=1; |
|
392 | + $showlineingray=0; |
|
393 | + |
|
394 | + // If there is filters to use |
|
395 | + if (is_array($taskrole)) |
|
396 | + { |
|
397 | + // If task not legitimate to show, search if a legitimate task exists later in tree |
|
398 | + if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
399 | + { |
|
400 | + // So search if task has a subtask legitimate to show |
|
401 | + $foundtaskforuserdeeper=0; |
|
402 | + searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); |
|
403 | + //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>'; |
|
404 | + if ($foundtaskforuserdeeper > 0) |
|
405 | + { |
|
406 | + $showlineingray=1; // We will show line but in gray |
|
407 | + } |
|
408 | + else |
|
409 | + { |
|
410 | + $showline=0; // No reason to show line |
|
411 | + } |
|
412 | + } |
|
413 | + } |
|
414 | + else |
|
415 | + { |
|
416 | + // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project |
|
417 | + // or into all other projects if user has permission to). |
|
418 | + if (empty($user->rights->projet->all->lire)) |
|
419 | + { |
|
420 | + // User is not allowed on this project and project is not public, so we hide line |
|
421 | + if (! in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
422 | + { |
|
423 | + // Note that having a user assigned to a task into a project user has no permission on, should not be possible |
|
424 | + // because assignement on task can be done only on contact of project. |
|
425 | + // If assignement was done and after, was removed from contact of project, then we can hide the line. |
|
426 | + $showline=0; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + |
|
431 | + if ($showline) |
|
432 | + { |
|
433 | + // Break on a new project |
|
434 | + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
435 | + { |
|
436 | + $var = !$var; |
|
437 | + $lastprojectid=$lines[$i]->fk_project; |
|
438 | + } |
|
439 | + |
|
440 | + print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; |
|
441 | + |
|
442 | + if ($showproject) |
|
443 | + { |
|
444 | + // Project ref |
|
445 | + print "<td>"; |
|
446 | + //if ($showlineingray) print '<i>'; |
|
447 | + $projectstatic->id=$lines[$i]->fk_project; |
|
448 | + $projectstatic->ref=$lines[$i]->projectref; |
|
449 | + $projectstatic->public=$lines[$i]->public; |
|
450 | + $projectstatic->title=$lines[$i]->projectlabel; |
|
451 | + if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
452 | + else print $projectstatic->getNomUrl(1,'nolink'); |
|
453 | + //if ($showlineingray) print '</i>'; |
|
454 | + print "</td>"; |
|
455 | + |
|
456 | + // Project status |
|
457 | + print '<td>'; |
|
458 | + $projectstatic->statut=$lines[$i]->projectstatus; |
|
459 | + print $projectstatic->getLibStatut(2); |
|
460 | + print "</td>"; |
|
461 | + } |
|
462 | + |
|
463 | + // Ref of task |
|
464 | + print '<td>'; |
|
465 | + if ($showlineingray) |
|
466 | + { |
|
467 | + print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>'; |
|
468 | + } |
|
469 | + else |
|
470 | + { |
|
471 | + $taskstatic->id=$lines[$i]->id; |
|
472 | + $taskstatic->ref=$lines[$i]->ref; |
|
473 | + $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); |
|
474 | + print $taskstatic->getNomUrl(1,'withproject'); |
|
475 | + } |
|
476 | + print '</td>'; |
|
477 | + |
|
478 | + // Title of task |
|
479 | + print "<td>"; |
|
480 | + if ($showlineingray) print '<i>'; |
|
481 | + //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">'; |
|
482 | + for ($k = 0 ; $k < $level ; $k++) |
|
483 | + { |
|
484 | + print " "; |
|
485 | + } |
|
486 | + print $lines[$i]->label; |
|
487 | + if ($showlineingray) print '</i>'; |
|
488 | + //else print '</a>'; |
|
489 | + print "</td>\n"; |
|
490 | + |
|
491 | + // Date start |
|
492 | + print '<td align="center">'; |
|
493 | + print dol_print_date($lines[$i]->date_start,'dayhour'); |
|
494 | + print '</td>'; |
|
495 | + |
|
496 | + // Date end |
|
497 | + print '<td align="center">'; |
|
498 | + $taskstatic->projectstatus = $lines[$i]->projectstatus; |
|
499 | + $taskstatic->progress = $lines[$i]->progress; |
|
500 | + $taskstatic->fk_statut = $lines[$i]->status; |
|
501 | + $taskstatic->datee = $lines[$i]->date_end; |
|
502 | + print dol_print_date($lines[$i]->date_end,'dayhour'); |
|
503 | + if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); |
|
504 | + print '</td>'; |
|
505 | + |
|
506 | + $plannedworkloadoutputformat='allhourmin'; |
|
507 | + $timespentoutputformat='allhourmin'; |
|
508 | + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
509 | + if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
510 | + |
|
511 | + // Planned Workload (in working hours) |
|
512 | + print '<td align="right">'; |
|
513 | + $fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat); |
|
514 | + $workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks |
|
515 | + if ($lines[$i]->planned_workload != '') |
|
516 | + { |
|
517 | + print $fullhour; |
|
518 | + // TODO Add delay taking account of working hours per day and working day per week |
|
519 | + //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')'; |
|
520 | + } |
|
521 | + //else print '--:--'; |
|
522 | + print '</td>'; |
|
523 | + |
|
524 | + // Time spent |
|
525 | + print '<td align="right">'; |
|
526 | + if ($showlineingray) print '<i>'; |
|
527 | + else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
528 | + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
529 | + else print '--:--'; |
|
530 | + if ($showlineingray) print '</i>'; |
|
531 | + else print '</a>'; |
|
532 | + print '</td>'; |
|
533 | + |
|
534 | + // Progress calculated (Note: ->duration is time spent) |
|
535 | + print '<td align="right">'; |
|
536 | + if ($lines[$i]->planned_workload || $lines[$i]->duration) |
|
537 | + { |
|
538 | + if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
539 | + else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
|
540 | + } |
|
541 | + print '</td>'; |
|
542 | + |
|
543 | + // Progress declared |
|
544 | + print '<td align="right">'; |
|
545 | + if ($lines[$i]->progress != '') |
|
546 | + { |
|
547 | + print $lines[$i]->progress.' %'; |
|
548 | + } |
|
549 | + print '</td>'; |
|
550 | + |
|
551 | + // Contacts of task |
|
552 | + if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
553 | + { |
|
554 | + print '<td>'; |
|
555 | + foreach(array('internal','external') as $source) |
|
556 | + { |
|
557 | + $tab = $lines[$i]->liste_contact(-1,$source); |
|
558 | + $num=count($tab); |
|
559 | + if (!empty($num)){ |
|
560 | + foreach ($tab as $contacttask){ |
|
561 | + //var_dump($contacttask); |
|
562 | + if ($source == 'internal') $c = new User($db); |
|
563 | + else $c = new Contact($db); |
|
564 | + $c->fetch($contacttask['id']); |
|
565 | + print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '<br>'; |
|
566 | + } |
|
567 | + } |
|
568 | + } |
|
569 | + print '</td>'; |
|
570 | + } |
|
571 | + |
|
572 | + // Tick to drag and drop |
|
573 | + if ($addordertick) |
|
574 | + { |
|
575 | + print '<td align="center" class="tdlineupdown hideonsmartphone"> </td>'; |
|
576 | + } |
|
577 | + |
|
578 | + print "</tr>\n"; |
|
579 | + |
|
580 | + if (! $showlineingray) $inc++; |
|
581 | + |
|
582 | + if ($level >= 0) // Call sublevels |
|
583 | + { |
|
584 | + $level++; |
|
585 | + if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); |
|
586 | + $level--; |
|
587 | + } |
|
588 | + |
|
589 | + $total_projectlinesa_spent += $lines[$i]->duration; |
|
590 | + $total_projectlinesa_planned += $lines[$i]->planned_workload; |
|
591 | + if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; |
|
592 | + } |
|
593 | + } |
|
594 | + else |
|
595 | + { |
|
596 | + //$level--; |
|
597 | + } |
|
598 | + } |
|
599 | + |
|
600 | + if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level <= 0) |
|
601 | + { |
|
602 | + print '<tr class="liste_total nodrag nodrop">'; |
|
603 | + print '<td class="liste_total">'.$langs->trans("Total").'</td>'; |
|
604 | + if ($showproject) print '<td></td><td></td>'; |
|
605 | + print '<td></td>'; |
|
606 | + print '<td></td>'; |
|
607 | + print '<td></td>'; |
|
608 | + print '<td align="right" class="nowrap liste_total">'; |
|
609 | + print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); |
|
610 | + print '</td>'; |
|
611 | + print '<td align="right" class="nowrap liste_total">'; |
|
612 | + if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
613 | + print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); |
|
614 | + if ($projectidfortotallink > 0) print '</a>'; |
|
615 | + print '</td>'; |
|
616 | + print '<td align="right" class="nowrap liste_total">'; |
|
617 | + if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
618 | + print '</td>'; |
|
619 | + print '<td></td>'; |
|
620 | + // Contacts of task |
|
621 | + if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
622 | + { |
|
623 | + print '<td></td>'; |
|
624 | + } |
|
625 | + if ($addordertick) print '<td class="hideonsmartphone"></td>'; |
|
626 | + print '</tr>'; |
|
627 | + } |
|
628 | + |
|
629 | + return $inc; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | |
@@ -649,191 +649,191 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
651 | 651 | { |
652 | - global $conf, $db, $user, $bc, $langs; |
|
653 | - global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
654 | - |
|
655 | - $lastprojectid=0; |
|
656 | - $totalforeachline=array(); |
|
657 | - $workloadforid=array(); |
|
658 | - $lineswithoutlevel0=array(); |
|
659 | - |
|
660 | - $numlines=count($lines); |
|
661 | - |
|
662 | - // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
663 | - if ($parent == 0) // Always and only if at first level |
|
664 | - { |
|
665 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
666 | - { |
|
667 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
668 | - } |
|
669 | - } |
|
670 | - |
|
671 | - if (empty($oldprojectforbreak)) |
|
672 | - { |
|
673 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
674 | - } |
|
675 | - |
|
676 | - //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
677 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
678 | - { |
|
679 | - if ($parent == 0) $level = 0; |
|
680 | - |
|
681 | - //if ($lines[$i]->fk_task_parent == $parent) |
|
682 | - //{ |
|
683 | - // If we want all or we have a role on task, we show it |
|
684 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
685 | - { |
|
686 | - //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
687 | - |
|
688 | - // Break on a new project |
|
689 | - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
690 | - { |
|
691 | - $lastprojectid=$lines[$i]->fk_project; |
|
692 | - if ($preselectedday) |
|
693 | - { |
|
694 | - $projectstatic->id = $lines[$i]->fk_project; |
|
695 | - } |
|
696 | - } |
|
697 | - |
|
698 | - if (empty($workloadforid[$projectstatic->id])) |
|
699 | - { |
|
700 | - if ($preselectedday) |
|
701 | - { |
|
702 | - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
703 | - $workloadforid[$projectstatic->id]=1; |
|
704 | - } |
|
705 | - } |
|
706 | - |
|
707 | - $projectstatic->id=$lines[$i]->fk_project; |
|
708 | - $projectstatic->ref=$lines[$i]->project_ref; |
|
709 | - $projectstatic->title=$lines[$i]->project_label; |
|
710 | - $projectstatic->public=$lines[$i]->public; |
|
711 | - |
|
712 | - $taskstatic->id=$lines[$i]->task_id; |
|
713 | - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); |
|
714 | - $taskstatic->label=$lines[$i]->task_label; |
|
715 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
716 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
717 | - |
|
718 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
719 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
720 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
721 | - |
|
722 | - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
723 | - { |
|
724 | - print '<tr class="oddeven trforbreak">'."\n"; |
|
725 | - print '<td colspan="11">'; |
|
726 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
727 | - if ($projectstatic->title) |
|
728 | - { |
|
729 | - print ' - '; |
|
730 | - print $projectstatic->title; |
|
731 | - } |
|
732 | - print '</td>'; |
|
733 | - print '</tr>'; |
|
734 | - } |
|
735 | - |
|
736 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
737 | - |
|
738 | - print '<tr class="oddeven">'."\n"; |
|
739 | - |
|
740 | - // User |
|
741 | - /* |
|
652 | + global $conf, $db, $user, $bc, $langs; |
|
653 | + global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
654 | + |
|
655 | + $lastprojectid=0; |
|
656 | + $totalforeachline=array(); |
|
657 | + $workloadforid=array(); |
|
658 | + $lineswithoutlevel0=array(); |
|
659 | + |
|
660 | + $numlines=count($lines); |
|
661 | + |
|
662 | + // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
663 | + if ($parent == 0) // Always and only if at first level |
|
664 | + { |
|
665 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
666 | + { |
|
667 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
668 | + } |
|
669 | + } |
|
670 | + |
|
671 | + if (empty($oldprojectforbreak)) |
|
672 | + { |
|
673 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
674 | + } |
|
675 | + |
|
676 | + //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
677 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
678 | + { |
|
679 | + if ($parent == 0) $level = 0; |
|
680 | + |
|
681 | + //if ($lines[$i]->fk_task_parent == $parent) |
|
682 | + //{ |
|
683 | + // If we want all or we have a role on task, we show it |
|
684 | + if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
685 | + { |
|
686 | + //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
687 | + |
|
688 | + // Break on a new project |
|
689 | + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
690 | + { |
|
691 | + $lastprojectid=$lines[$i]->fk_project; |
|
692 | + if ($preselectedday) |
|
693 | + { |
|
694 | + $projectstatic->id = $lines[$i]->fk_project; |
|
695 | + } |
|
696 | + } |
|
697 | + |
|
698 | + if (empty($workloadforid[$projectstatic->id])) |
|
699 | + { |
|
700 | + if ($preselectedday) |
|
701 | + { |
|
702 | + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
703 | + $workloadforid[$projectstatic->id]=1; |
|
704 | + } |
|
705 | + } |
|
706 | + |
|
707 | + $projectstatic->id=$lines[$i]->fk_project; |
|
708 | + $projectstatic->ref=$lines[$i]->project_ref; |
|
709 | + $projectstatic->title=$lines[$i]->project_label; |
|
710 | + $projectstatic->public=$lines[$i]->public; |
|
711 | + |
|
712 | + $taskstatic->id=$lines[$i]->task_id; |
|
713 | + $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); |
|
714 | + $taskstatic->label=$lines[$i]->task_label; |
|
715 | + $taskstatic->date_start=$lines[$i]->date_start; |
|
716 | + $taskstatic->date_end=$lines[$i]->date_end; |
|
717 | + |
|
718 | + $thirdpartystatic->id=$lines[$i]->socid; |
|
719 | + $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
720 | + $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
721 | + |
|
722 | + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
723 | + { |
|
724 | + print '<tr class="oddeven trforbreak">'."\n"; |
|
725 | + print '<td colspan="11">'; |
|
726 | + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
727 | + if ($projectstatic->title) |
|
728 | + { |
|
729 | + print ' - '; |
|
730 | + print $projectstatic->title; |
|
731 | + } |
|
732 | + print '</td>'; |
|
733 | + print '</tr>'; |
|
734 | + } |
|
735 | + |
|
736 | + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
737 | + |
|
738 | + print '<tr class="oddeven">'."\n"; |
|
739 | + |
|
740 | + // User |
|
741 | + /* |
|
742 | 742 | print '<td class="nowrap">'; |
743 | 743 | print $fuser->getNomUrl(1, 'withproject', 'time'); |
744 | 744 | print '</td>'; |
745 | 745 | */ |
746 | 746 | |
747 | - // Project |
|
748 | - print "<td>"; |
|
749 | - if ($oldprojectforbreak == -1) |
|
750 | - { |
|
751 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
752 | - print '<br>'.$projectstatic->title; |
|
753 | - } |
|
754 | - print "</td>"; |
|
755 | - |
|
756 | - // Thirdparty |
|
757 | - print '<td class="tdoverflowmax100">'; |
|
758 | - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
759 | - print '</td>'; |
|
760 | - |
|
761 | - // Ref |
|
762 | - print '<td>'; |
|
763 | - print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
764 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
765 | - print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
766 | - // Label task |
|
767 | - print '<br>'; |
|
768 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
769 | - print $taskstatic->label; |
|
770 | - //print "<br>"; |
|
771 | - //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
772 | - //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
773 | - print "</td>\n"; |
|
774 | - |
|
775 | - // Date |
|
776 | - print '<td align="center">'; |
|
777 | - print dol_print_date($lines[$i]->timespent_datehour,'day'); |
|
778 | - print '</td>'; |
|
779 | - |
|
780 | - $disabledproject=1;$disabledtask=1; |
|
781 | - //print "x".$lines[$i]->fk_project; |
|
782 | - //var_dump($lines[$i]); |
|
783 | - //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
784 | - // If at least one role for project |
|
785 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
786 | - { |
|
787 | - $disabledproject=0; |
|
788 | - $disabledtask=0; |
|
789 | - } |
|
790 | - // If $restricteditformytask is on and I have no role on task, i disable edit |
|
791 | - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
792 | - { |
|
793 | - $disabledtask=1; |
|
794 | - } |
|
795 | - |
|
796 | - // Hour |
|
797 | - print '<td class="nowrap" align="center">'; |
|
798 | - print dol_print_date($lines[$i]->timespent_datehour,'hour'); |
|
799 | - print '</td>'; |
|
800 | - |
|
801 | - $cssonholiday=''; |
|
802 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
803 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
804 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
805 | - |
|
806 | - // Duration |
|
807 | - print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
|
808 | - |
|
809 | - $dayWorkLoad = $lines[$i]->timespent_duration; |
|
810 | - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
|
811 | - |
|
812 | - $alreadyspent=''; |
|
813 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
814 | - |
|
815 | - print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
816 | - |
|
817 | - $modeinput='hours'; |
|
818 | - |
|
819 | - print '<script type="text/javascript">'; |
|
820 | - print "jQuery(document).ready(function () {\n"; |
|
821 | - print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });"; |
|
822 | - print "})\n"; |
|
823 | - print '</script>'; |
|
824 | - |
|
825 | - print '</td>'; |
|
826 | - |
|
827 | - // Note |
|
828 | - print '<td align="center">'; |
|
829 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
830 | - print $lines[$i]->timespent_note; |
|
831 | - print '</textarea>'; |
|
832 | - print '</td>'; |
|
833 | - |
|
834 | - // Warning |
|
835 | - print '<td align="right">'; |
|
836 | - /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
747 | + // Project |
|
748 | + print "<td>"; |
|
749 | + if ($oldprojectforbreak == -1) |
|
750 | + { |
|
751 | + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
752 | + print '<br>'.$projectstatic->title; |
|
753 | + } |
|
754 | + print "</td>"; |
|
755 | + |
|
756 | + // Thirdparty |
|
757 | + print '<td class="tdoverflowmax100">'; |
|
758 | + if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
759 | + print '</td>'; |
|
760 | + |
|
761 | + // Ref |
|
762 | + print '<td>'; |
|
763 | + print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
764 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
765 | + print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
766 | + // Label task |
|
767 | + print '<br>'; |
|
768 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
769 | + print $taskstatic->label; |
|
770 | + //print "<br>"; |
|
771 | + //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
772 | + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
773 | + print "</td>\n"; |
|
774 | + |
|
775 | + // Date |
|
776 | + print '<td align="center">'; |
|
777 | + print dol_print_date($lines[$i]->timespent_datehour,'day'); |
|
778 | + print '</td>'; |
|
779 | + |
|
780 | + $disabledproject=1;$disabledtask=1; |
|
781 | + //print "x".$lines[$i]->fk_project; |
|
782 | + //var_dump($lines[$i]); |
|
783 | + //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
784 | + // If at least one role for project |
|
785 | + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
786 | + { |
|
787 | + $disabledproject=0; |
|
788 | + $disabledtask=0; |
|
789 | + } |
|
790 | + // If $restricteditformytask is on and I have no role on task, i disable edit |
|
791 | + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
792 | + { |
|
793 | + $disabledtask=1; |
|
794 | + } |
|
795 | + |
|
796 | + // Hour |
|
797 | + print '<td class="nowrap" align="center">'; |
|
798 | + print dol_print_date($lines[$i]->timespent_datehour,'hour'); |
|
799 | + print '</td>'; |
|
800 | + |
|
801 | + $cssonholiday=''; |
|
802 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
803 | + elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
804 | + elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
805 | + |
|
806 | + // Duration |
|
807 | + print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
|
808 | + |
|
809 | + $dayWorkLoad = $lines[$i]->timespent_duration; |
|
810 | + $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
|
811 | + |
|
812 | + $alreadyspent=''; |
|
813 | + if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
814 | + |
|
815 | + print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
816 | + |
|
817 | + $modeinput='hours'; |
|
818 | + |
|
819 | + print '<script type="text/javascript">'; |
|
820 | + print "jQuery(document).ready(function () {\n"; |
|
821 | + print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });"; |
|
822 | + print "})\n"; |
|
823 | + print '</script>'; |
|
824 | + |
|
825 | + print '</td>'; |
|
826 | + |
|
827 | + // Note |
|
828 | + print '<td align="center">'; |
|
829 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
830 | + print $lines[$i]->timespent_note; |
|
831 | + print '</textarea>'; |
|
832 | + print '</td>'; |
|
833 | + |
|
834 | + // Warning |
|
835 | + print '<td align="right">'; |
|
836 | + /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
837 | 837 | else if ($disabledtask) |
838 | 838 | { |
839 | 839 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | |
842 | 842 | print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
843 | 843 | }*/ |
844 | - print '</td>'; |
|
845 | - |
|
846 | - print "</tr>\n"; |
|
847 | - } |
|
848 | - //} |
|
849 | - //else |
|
850 | - //{ |
|
851 | - //$level--; |
|
852 | - //} |
|
853 | - } |
|
854 | - |
|
855 | - return $totalforeachline; |
|
844 | + print '</td>'; |
|
845 | + |
|
846 | + print "</tr>\n"; |
|
847 | + } |
|
848 | + //} |
|
849 | + //else |
|
850 | + //{ |
|
851 | + //$level--; |
|
852 | + //} |
|
853 | + } |
|
854 | + |
|
855 | + return $totalforeachline; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | |
@@ -875,273 +875,273 @@ discard block |
||
875 | 875 | */ |
876 | 876 | function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
877 | 877 | { |
878 | - global $conf, $db, $user, $bc, $langs; |
|
879 | - global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
880 | - |
|
881 | - $lastprojectid=0; |
|
882 | - $totalforeachday=array(); |
|
883 | - $workloadforid=array(); |
|
884 | - $lineswithoutlevel0=array(); |
|
885 | - |
|
886 | - $numlines=count($lines); |
|
887 | - |
|
888 | - // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
889 | - if ($parent == 0) // Always and only if at first level |
|
890 | - { |
|
891 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
892 | - { |
|
893 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
894 | - } |
|
895 | - } |
|
896 | - |
|
897 | - if (empty($oldprojectforbreak)) |
|
898 | - { |
|
899 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
900 | - } |
|
901 | - |
|
902 | - //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
903 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
904 | - { |
|
905 | - if ($parent == 0) $level = 0; |
|
906 | - |
|
907 | - if ($lines[$i]->fk_task_parent == $parent) |
|
908 | - { |
|
909 | - // If we want all or we have a role on task, we show it |
|
910 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
911 | - { |
|
912 | - //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
913 | - |
|
914 | - if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases |
|
915 | - { |
|
916 | - continue; |
|
917 | - } |
|
918 | - |
|
919 | - // Break on a new project |
|
920 | - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
921 | - { |
|
922 | - $lastprojectid=$lines[$i]->fk_project; |
|
923 | - if ($preselectedday) |
|
924 | - { |
|
925 | - $projectstatic->id = $lines[$i]->fk_project; |
|
926 | - } |
|
927 | - } |
|
928 | - |
|
929 | - if (empty($workloadforid[$projectstatic->id])) |
|
930 | - { |
|
931 | - if ($preselectedday) |
|
932 | - { |
|
933 | - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
934 | - $workloadforid[$projectstatic->id]=1; |
|
935 | - } |
|
936 | - } |
|
937 | - |
|
938 | - $projectstatic->id=$lines[$i]->fk_project; |
|
939 | - $projectstatic->ref=$lines[$i]->projectref; |
|
940 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
941 | - $projectstatic->public=$lines[$i]->public; |
|
942 | - |
|
943 | - $taskstatic->id=$lines[$i]->id; |
|
944 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
945 | - $taskstatic->label=$lines[$i]->label; |
|
946 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
947 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
948 | - |
|
949 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
950 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
951 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
952 | - |
|
953 | - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
954 | - { |
|
955 | - print '<tr class="oddeven trforbreak">'."\n"; |
|
956 | - print '<td colspan="9">'; |
|
957 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
958 | - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
959 | - if ($projectstatic->title) |
|
960 | - { |
|
961 | - print ' - '; |
|
962 | - print $projectstatic->title; |
|
963 | - } |
|
964 | - print '</td>'; |
|
965 | - print '</tr>'; |
|
966 | - } |
|
967 | - |
|
968 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
969 | - |
|
970 | - print '<tr class="oddeven">'."\n"; |
|
971 | - |
|
972 | - // User |
|
973 | - /* |
|
878 | + global $conf, $db, $user, $bc, $langs; |
|
879 | + global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
880 | + |
|
881 | + $lastprojectid=0; |
|
882 | + $totalforeachday=array(); |
|
883 | + $workloadforid=array(); |
|
884 | + $lineswithoutlevel0=array(); |
|
885 | + |
|
886 | + $numlines=count($lines); |
|
887 | + |
|
888 | + // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
889 | + if ($parent == 0) // Always and only if at first level |
|
890 | + { |
|
891 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
892 | + { |
|
893 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
894 | + } |
|
895 | + } |
|
896 | + |
|
897 | + if (empty($oldprojectforbreak)) |
|
898 | + { |
|
899 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
900 | + } |
|
901 | + |
|
902 | + //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
903 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
904 | + { |
|
905 | + if ($parent == 0) $level = 0; |
|
906 | + |
|
907 | + if ($lines[$i]->fk_task_parent == $parent) |
|
908 | + { |
|
909 | + // If we want all or we have a role on task, we show it |
|
910 | + if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
911 | + { |
|
912 | + //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
913 | + |
|
914 | + if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases |
|
915 | + { |
|
916 | + continue; |
|
917 | + } |
|
918 | + |
|
919 | + // Break on a new project |
|
920 | + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
921 | + { |
|
922 | + $lastprojectid=$lines[$i]->fk_project; |
|
923 | + if ($preselectedday) |
|
924 | + { |
|
925 | + $projectstatic->id = $lines[$i]->fk_project; |
|
926 | + } |
|
927 | + } |
|
928 | + |
|
929 | + if (empty($workloadforid[$projectstatic->id])) |
|
930 | + { |
|
931 | + if ($preselectedday) |
|
932 | + { |
|
933 | + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
934 | + $workloadforid[$projectstatic->id]=1; |
|
935 | + } |
|
936 | + } |
|
937 | + |
|
938 | + $projectstatic->id=$lines[$i]->fk_project; |
|
939 | + $projectstatic->ref=$lines[$i]->projectref; |
|
940 | + $projectstatic->title=$lines[$i]->projectlabel; |
|
941 | + $projectstatic->public=$lines[$i]->public; |
|
942 | + |
|
943 | + $taskstatic->id=$lines[$i]->id; |
|
944 | + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
945 | + $taskstatic->label=$lines[$i]->label; |
|
946 | + $taskstatic->date_start=$lines[$i]->date_start; |
|
947 | + $taskstatic->date_end=$lines[$i]->date_end; |
|
948 | + |
|
949 | + $thirdpartystatic->id=$lines[$i]->socid; |
|
950 | + $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
951 | + $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
952 | + |
|
953 | + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
954 | + { |
|
955 | + print '<tr class="oddeven trforbreak">'."\n"; |
|
956 | + print '<td colspan="9">'; |
|
957 | + print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
958 | + if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
959 | + if ($projectstatic->title) |
|
960 | + { |
|
961 | + print ' - '; |
|
962 | + print $projectstatic->title; |
|
963 | + } |
|
964 | + print '</td>'; |
|
965 | + print '</tr>'; |
|
966 | + } |
|
967 | + |
|
968 | + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
969 | + |
|
970 | + print '<tr class="oddeven">'."\n"; |
|
971 | + |
|
972 | + // User |
|
973 | + /* |
|
974 | 974 | print '<td class="nowrap">'; |
975 | 975 | print $fuser->getNomUrl(1, 'withproject', 'time'); |
976 | 976 | print '</td>'; |
977 | 977 | */ |
978 | 978 | |
979 | - // Project |
|
980 | - /*print "<td>"; |
|
979 | + // Project |
|
980 | + /*print "<td>"; |
|
981 | 981 | if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
982 | 982 | print "</td>";*/ |
983 | 983 | |
984 | - // Thirdparty |
|
985 | - /*print '<td class="tdoverflowmax100">'; |
|
984 | + // Thirdparty |
|
985 | + /*print '<td class="tdoverflowmax100">'; |
|
986 | 986 | if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
987 | 987 | print '</td>';*/ |
988 | 988 | |
989 | - // Ref |
|
990 | - print '<td>'; |
|
991 | - print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
992 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
993 | - print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
994 | - // Label task |
|
995 | - print '<br>'; |
|
996 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
997 | - print $taskstatic->label; |
|
998 | - //print "<br>"; |
|
999 | - //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1000 | - //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
1001 | - print "</td>\n"; |
|
1002 | - |
|
1003 | - // Planned Workload |
|
1004 | - print '<td align="right" class="leftborder plannedworkload">'; |
|
1005 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1006 | - else print '--:--'; |
|
1007 | - print '</td>'; |
|
1008 | - |
|
1009 | - // Progress declared % |
|
1010 | - print '<td align="right">'; |
|
1011 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1012 | - print '</td>'; |
|
1013 | - |
|
1014 | - // Time spent by everybody |
|
1015 | - print '<td align="right">'; |
|
1016 | - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user |
|
1017 | - if ($lines[$i]->duration) |
|
1018 | - { |
|
1019 | - print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
|
1020 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1021 | - print '</a>'; |
|
1022 | - } |
|
1023 | - else print '--:--'; |
|
1024 | - print "</td>\n"; |
|
1025 | - |
|
1026 | - // Time spent by user |
|
1027 | - print '<td align="right">'; |
|
1028 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1029 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1030 | - else print '--:--'; |
|
1031 | - print "</td>\n"; |
|
1032 | - |
|
1033 | - $disabledproject=1;$disabledtask=1; |
|
1034 | - //print "x".$lines[$i]->fk_project; |
|
1035 | - //var_dump($lines[$i]); |
|
1036 | - //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
1037 | - // If at least one role for project |
|
1038 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1039 | - { |
|
1040 | - $disabledproject=0; |
|
1041 | - $disabledtask=0; |
|
1042 | - } |
|
1043 | - // If $restricteditformytask is on and I have no role on task, i disable edit |
|
1044 | - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
1045 | - { |
|
1046 | - $disabledtask=1; |
|
1047 | - } |
|
1048 | - |
|
1049 | - // Form to add new time |
|
1050 | - print '<td class="nowrap leftborder" align="center">'; |
|
1051 | - $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask); |
|
1052 | - print $tableCell; |
|
1053 | - print '</td>'; |
|
1054 | - |
|
1055 | - $cssonholiday=''; |
|
1056 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1057 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1058 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1059 | - |
|
1060 | - global $daytoparse; |
|
1061 | - $tmparray = dol_getdate($daytoparse,true); // detail of current day |
|
1062 | - $idw = $tmparray['wday']; |
|
1063 | - |
|
1064 | - global $numstartworkingday, $numendworkingday; |
|
1065 | - $cssweekend=''; |
|
1066 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
1067 | - { |
|
1068 | - $cssweekend='weekend'; |
|
1069 | - } |
|
1070 | - |
|
1071 | - // Duration |
|
1072 | - print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1073 | - $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; |
|
1074 | - $totalforeachday[$preselectedday]+=$dayWorkLoad; |
|
1075 | - |
|
1076 | - $alreadyspent=''; |
|
1077 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1078 | - |
|
1079 | - $idw = 0; |
|
1080 | - |
|
1081 | - $tableCell=''; |
|
1082 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
1083 | - $tableCell.='<span class="hideonsmartphone"> + </span>'; |
|
1084 | - //$tableCell.=' '; |
|
1085 | - $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); |
|
1086 | - //$tableCell.=' <input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">'; |
|
1087 | - print $tableCell; |
|
1088 | - |
|
1089 | - $modeinput='hours'; |
|
1090 | - |
|
1091 | - print '<script type="text/javascript">'; |
|
1092 | - print "jQuery(document).ready(function () {\n"; |
|
1093 | - print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });"; |
|
1094 | - print "})\n"; |
|
1095 | - print '</script>'; |
|
1096 | - |
|
1097 | - print '</td>'; |
|
1098 | - |
|
1099 | - // Note |
|
1100 | - print '<td align="center">'; |
|
1101 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
1102 | - print '</textarea>'; |
|
1103 | - print '</td>'; |
|
1104 | - |
|
1105 | - // Warning |
|
1106 | - print '<td align="right">'; |
|
1107 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1108 | - else if ($disabledtask) |
|
1109 | - { |
|
1110 | - $titleassigntask = $langs->trans("AssignTaskToMe"); |
|
1111 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
1112 | - |
|
1113 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1114 | - } |
|
1115 | - print '</td>'; |
|
1116 | - |
|
1117 | - print "</tr>\n"; |
|
1118 | - } |
|
1119 | - |
|
1120 | - $inc++; |
|
1121 | - $level++; |
|
1122 | - if ($lines[$i]->id > 0) |
|
1123 | - { |
|
1124 | - //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); |
|
1125 | - //var_dump($totalforeachday); |
|
1126 | - $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); |
|
1127 | - //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
|
1128 | - //var_dump($ret); |
|
1129 | - foreach($ret as $key => $val) |
|
1130 | - { |
|
1131 | - $totalforeachday[$key]+=$val; |
|
1132 | - } |
|
1133 | - //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
|
1134 | - //var_dump($totalforeachday); |
|
1135 | - } |
|
1136 | - $level--; |
|
1137 | - } |
|
1138 | - else |
|
1139 | - { |
|
1140 | - //$level--; |
|
1141 | - } |
|
1142 | - } |
|
1143 | - |
|
1144 | - return $totalforeachday; |
|
989 | + // Ref |
|
990 | + print '<td>'; |
|
991 | + print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
992 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
993 | + print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
994 | + // Label task |
|
995 | + print '<br>'; |
|
996 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
997 | + print $taskstatic->label; |
|
998 | + //print "<br>"; |
|
999 | + //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1000 | + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
1001 | + print "</td>\n"; |
|
1002 | + |
|
1003 | + // Planned Workload |
|
1004 | + print '<td align="right" class="leftborder plannedworkload">'; |
|
1005 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1006 | + else print '--:--'; |
|
1007 | + print '</td>'; |
|
1008 | + |
|
1009 | + // Progress declared % |
|
1010 | + print '<td align="right">'; |
|
1011 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1012 | + print '</td>'; |
|
1013 | + |
|
1014 | + // Time spent by everybody |
|
1015 | + print '<td align="right">'; |
|
1016 | + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user |
|
1017 | + if ($lines[$i]->duration) |
|
1018 | + { |
|
1019 | + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
|
1020 | + print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1021 | + print '</a>'; |
|
1022 | + } |
|
1023 | + else print '--:--'; |
|
1024 | + print "</td>\n"; |
|
1025 | + |
|
1026 | + // Time spent by user |
|
1027 | + print '<td align="right">'; |
|
1028 | + $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1029 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1030 | + else print '--:--'; |
|
1031 | + print "</td>\n"; |
|
1032 | + |
|
1033 | + $disabledproject=1;$disabledtask=1; |
|
1034 | + //print "x".$lines[$i]->fk_project; |
|
1035 | + //var_dump($lines[$i]); |
|
1036 | + //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
1037 | + // If at least one role for project |
|
1038 | + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1039 | + { |
|
1040 | + $disabledproject=0; |
|
1041 | + $disabledtask=0; |
|
1042 | + } |
|
1043 | + // If $restricteditformytask is on and I have no role on task, i disable edit |
|
1044 | + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
1045 | + { |
|
1046 | + $disabledtask=1; |
|
1047 | + } |
|
1048 | + |
|
1049 | + // Form to add new time |
|
1050 | + print '<td class="nowrap leftborder" align="center">'; |
|
1051 | + $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask); |
|
1052 | + print $tableCell; |
|
1053 | + print '</td>'; |
|
1054 | + |
|
1055 | + $cssonholiday=''; |
|
1056 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1057 | + elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1058 | + elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1059 | + |
|
1060 | + global $daytoparse; |
|
1061 | + $tmparray = dol_getdate($daytoparse,true); // detail of current day |
|
1062 | + $idw = $tmparray['wday']; |
|
1063 | + |
|
1064 | + global $numstartworkingday, $numendworkingday; |
|
1065 | + $cssweekend=''; |
|
1066 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
1067 | + { |
|
1068 | + $cssweekend='weekend'; |
|
1069 | + } |
|
1070 | + |
|
1071 | + // Duration |
|
1072 | + print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1073 | + $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; |
|
1074 | + $totalforeachday[$preselectedday]+=$dayWorkLoad; |
|
1075 | + |
|
1076 | + $alreadyspent=''; |
|
1077 | + if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1078 | + |
|
1079 | + $idw = 0; |
|
1080 | + |
|
1081 | + $tableCell=''; |
|
1082 | + $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
1083 | + $tableCell.='<span class="hideonsmartphone"> + </span>'; |
|
1084 | + //$tableCell.=' '; |
|
1085 | + $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); |
|
1086 | + //$tableCell.=' <input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">'; |
|
1087 | + print $tableCell; |
|
1088 | + |
|
1089 | + $modeinput='hours'; |
|
1090 | + |
|
1091 | + print '<script type="text/javascript">'; |
|
1092 | + print "jQuery(document).ready(function () {\n"; |
|
1093 | + print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });"; |
|
1094 | + print "})\n"; |
|
1095 | + print '</script>'; |
|
1096 | + |
|
1097 | + print '</td>'; |
|
1098 | + |
|
1099 | + // Note |
|
1100 | + print '<td align="center">'; |
|
1101 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
1102 | + print '</textarea>'; |
|
1103 | + print '</td>'; |
|
1104 | + |
|
1105 | + // Warning |
|
1106 | + print '<td align="right">'; |
|
1107 | + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1108 | + else if ($disabledtask) |
|
1109 | + { |
|
1110 | + $titleassigntask = $langs->trans("AssignTaskToMe"); |
|
1111 | + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
1112 | + |
|
1113 | + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1114 | + } |
|
1115 | + print '</td>'; |
|
1116 | + |
|
1117 | + print "</tr>\n"; |
|
1118 | + } |
|
1119 | + |
|
1120 | + $inc++; |
|
1121 | + $level++; |
|
1122 | + if ($lines[$i]->id > 0) |
|
1123 | + { |
|
1124 | + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); |
|
1125 | + //var_dump($totalforeachday); |
|
1126 | + $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); |
|
1127 | + //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
|
1128 | + //var_dump($ret); |
|
1129 | + foreach($ret as $key => $val) |
|
1130 | + { |
|
1131 | + $totalforeachday[$key]+=$val; |
|
1132 | + } |
|
1133 | + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
|
1134 | + //var_dump($totalforeachday); |
|
1135 | + } |
|
1136 | + $level--; |
|
1137 | + } |
|
1138 | + else |
|
1139 | + { |
|
1140 | + //$level--; |
|
1141 | + } |
|
1142 | + } |
|
1143 | + |
|
1144 | + return $totalforeachday; |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1164,263 +1164,263 @@ discard block |
||
1164 | 1164 | */ |
1165 | 1165 | function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0) |
1166 | 1166 | { |
1167 | - global $conf, $db, $user, $bc, $langs; |
|
1168 | - global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
1169 | - |
|
1170 | - $numlines=count($lines); |
|
1171 | - |
|
1172 | - $lastprojectid=0; |
|
1173 | - $workloadforid=array(); |
|
1174 | - $totalforeachday=array(); |
|
1175 | - $lineswithoutlevel0=array(); |
|
1176 | - |
|
1177 | - // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
1178 | - if ($parent == 0) // Always and only if at first level |
|
1179 | - { |
|
1180 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1181 | - { |
|
1182 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
1183 | - } |
|
1184 | - } |
|
1185 | - |
|
1186 | - //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
1187 | - |
|
1188 | - if (empty($oldprojectforbreak)) |
|
1189 | - { |
|
1190 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break |
|
1191 | - } |
|
1192 | - |
|
1193 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1194 | - { |
|
1195 | - if ($parent == 0) $level = 0; |
|
1196 | - |
|
1197 | - if ($lines[$i]->fk_task_parent == $parent) |
|
1198 | - { |
|
1199 | - // If we want all or we have a role on task, we show it |
|
1200 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
1201 | - { |
|
1202 | - //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
1203 | - |
|
1204 | - if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases |
|
1205 | - { |
|
1206 | - continue; |
|
1207 | - } |
|
1208 | - |
|
1209 | - // Break on a new project |
|
1210 | - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
1211 | - { |
|
1212 | - $lastprojectid=$lines[$i]->fk_project; |
|
1213 | - $projectstatic->id = $lines[$i]->fk_project; |
|
1214 | - } |
|
1215 | - |
|
1216 | - //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
|
1217 | - //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1218 | - if (empty($workloadforid[$projectstatic->id])) |
|
1219 | - { |
|
1220 | - $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
1221 | - $workloadforid[$projectstatic->id]=1; |
|
1222 | - } |
|
1223 | - //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1224 | - //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
|
1225 | - |
|
1226 | - $projectstatic->id=$lines[$i]->fk_project; |
|
1227 | - $projectstatic->ref=$lines[$i]->projectref; |
|
1228 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
1229 | - $projectstatic->public=$lines[$i]->public; |
|
1230 | - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; |
|
1231 | - |
|
1232 | - $taskstatic->id=$lines[$i]->id; |
|
1233 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
1234 | - $taskstatic->label=$lines[$i]->label; |
|
1235 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
1236 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
1237 | - |
|
1238 | - $thirdpartystatic->id=$lines[$i]->thirdparty_id; |
|
1239 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
1240 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
1241 | - |
|
1242 | - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
1243 | - { |
|
1244 | - print '<tr class="oddeven trforbreak">'."\n"; |
|
1245 | - print '<td colspan="13">'; |
|
1246 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
1247 | - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
1248 | - if ($projectstatic->title) |
|
1249 | - { |
|
1250 | - print ' - '; |
|
1251 | - print $projectstatic->title; |
|
1252 | - } |
|
1253 | - print '</td>'; |
|
1254 | - print '</tr>'; |
|
1255 | - } |
|
1256 | - |
|
1257 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
1258 | - |
|
1259 | - print '<tr class="oddeven">'."\n"; |
|
1260 | - |
|
1261 | - // User |
|
1262 | - /* |
|
1167 | + global $conf, $db, $user, $bc, $langs; |
|
1168 | + global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
|
1169 | + |
|
1170 | + $numlines=count($lines); |
|
1171 | + |
|
1172 | + $lastprojectid=0; |
|
1173 | + $workloadforid=array(); |
|
1174 | + $totalforeachday=array(); |
|
1175 | + $lineswithoutlevel0=array(); |
|
1176 | + |
|
1177 | + // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
|
1178 | + if ($parent == 0) // Always and only if at first level |
|
1179 | + { |
|
1180 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
1181 | + { |
|
1182 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
1183 | + } |
|
1184 | + } |
|
1185 | + |
|
1186 | + //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
|
1187 | + |
|
1188 | + if (empty($oldprojectforbreak)) |
|
1189 | + { |
|
1190 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break |
|
1191 | + } |
|
1192 | + |
|
1193 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
1194 | + { |
|
1195 | + if ($parent == 0) $level = 0; |
|
1196 | + |
|
1197 | + if ($lines[$i]->fk_task_parent == $parent) |
|
1198 | + { |
|
1199 | + // If we want all or we have a role on task, we show it |
|
1200 | + if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
1201 | + { |
|
1202 | + //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
|
1203 | + |
|
1204 | + if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases |
|
1205 | + { |
|
1206 | + continue; |
|
1207 | + } |
|
1208 | + |
|
1209 | + // Break on a new project |
|
1210 | + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
|
1211 | + { |
|
1212 | + $lastprojectid=$lines[$i]->fk_project; |
|
1213 | + $projectstatic->id = $lines[$i]->fk_project; |
|
1214 | + } |
|
1215 | + |
|
1216 | + //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
|
1217 | + //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1218 | + if (empty($workloadforid[$projectstatic->id])) |
|
1219 | + { |
|
1220 | + $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
1221 | + $workloadforid[$projectstatic->id]=1; |
|
1222 | + } |
|
1223 | + //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1224 | + //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
|
1225 | + |
|
1226 | + $projectstatic->id=$lines[$i]->fk_project; |
|
1227 | + $projectstatic->ref=$lines[$i]->projectref; |
|
1228 | + $projectstatic->title=$lines[$i]->projectlabel; |
|
1229 | + $projectstatic->public=$lines[$i]->public; |
|
1230 | + $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; |
|
1231 | + |
|
1232 | + $taskstatic->id=$lines[$i]->id; |
|
1233 | + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
1234 | + $taskstatic->label=$lines[$i]->label; |
|
1235 | + $taskstatic->date_start=$lines[$i]->date_start; |
|
1236 | + $taskstatic->date_end=$lines[$i]->date_end; |
|
1237 | + |
|
1238 | + $thirdpartystatic->id=$lines[$i]->thirdparty_id; |
|
1239 | + $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
1240 | + $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
1241 | + |
|
1242 | + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
|
1243 | + { |
|
1244 | + print '<tr class="oddeven trforbreak">'."\n"; |
|
1245 | + print '<td colspan="13">'; |
|
1246 | + print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
1247 | + if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
1248 | + if ($projectstatic->title) |
|
1249 | + { |
|
1250 | + print ' - '; |
|
1251 | + print $projectstatic->title; |
|
1252 | + } |
|
1253 | + print '</td>'; |
|
1254 | + print '</tr>'; |
|
1255 | + } |
|
1256 | + |
|
1257 | + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
1258 | + |
|
1259 | + print '<tr class="oddeven">'."\n"; |
|
1260 | + |
|
1261 | + // User |
|
1262 | + /* |
|
1263 | 1263 | print '<td class="nowrap">'; |
1264 | 1264 | print $fuser->getNomUrl(1, 'withproject', 'time'); |
1265 | 1265 | print '</td>'; |
1266 | 1266 | */ |
1267 | 1267 | |
1268 | - // Project |
|
1269 | - /*print '<td class="nowrap">'; |
|
1268 | + // Project |
|
1269 | + /*print '<td class="nowrap">'; |
|
1270 | 1270 | if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
1271 | 1271 | print "</td>";*/ |
1272 | 1272 | |
1273 | - // Thirdparty |
|
1274 | - /*print '<td class="tdoverflowmax100">'; |
|
1273 | + // Thirdparty |
|
1274 | + /*print '<td class="tdoverflowmax100">'; |
|
1275 | 1275 | if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); |
1276 | 1276 | print '</td>';*/ |
1277 | 1277 | |
1278 | - // Ref |
|
1279 | - print '<td class="nowrap">'; |
|
1280 | - print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
1281 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1282 | - print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
1283 | - // Label task |
|
1284 | - print '<br>'; |
|
1285 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1286 | - //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
|
1287 | - print $taskstatic->label; |
|
1288 | - //print "<br>"; |
|
1289 | - //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1290 | - //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
1291 | - print "</td>\n"; |
|
1292 | - |
|
1293 | - // Planned Workload |
|
1294 | - print '<td align="right" class="leftborder plannedworkload">'; |
|
1295 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1296 | - else print '--:--'; |
|
1297 | - print '</td>'; |
|
1298 | - |
|
1299 | - // Progress declared % |
|
1300 | - print '<td align="right">'; |
|
1301 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1302 | - print '</td>'; |
|
1303 | - |
|
1304 | - // Time spent by everybody |
|
1305 | - print '<td align="right">'; |
|
1306 | - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user |
|
1307 | - if ($lines[$i]->duration) |
|
1308 | - { |
|
1309 | - print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
|
1310 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1311 | - print '</a>'; |
|
1312 | - } |
|
1313 | - else print '--:--'; |
|
1314 | - print "</td>\n"; |
|
1315 | - |
|
1316 | - // Time spent by user |
|
1317 | - print '<td align="right">'; |
|
1318 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1319 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1320 | - else print '--:--'; |
|
1321 | - print "</td>\n"; |
|
1322 | - |
|
1323 | - $disabledproject=1;$disabledtask=1; |
|
1324 | - //print "x".$lines[$i]->fk_project; |
|
1325 | - //var_dump($lines[$i]); |
|
1326 | - //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
1327 | - // If at least one role for project |
|
1328 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1329 | - { |
|
1330 | - $disabledproject=0; |
|
1331 | - $disabledtask=0; |
|
1332 | - } |
|
1333 | - // If $restricteditformytask is on and I have no role on task, i disable edit |
|
1334 | - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
1335 | - { |
|
1336 | - $disabledtask=1; |
|
1337 | - } |
|
1338 | - |
|
1339 | - //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1340 | - |
|
1341 | - // Fields to show current time |
|
1342 | - $tableCell=''; $modeinput='hours'; |
|
1343 | - for ($idw = 0; $idw < 7; $idw++) |
|
1344 | - { |
|
1345 | - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
1346 | - |
|
1347 | - $cssonholiday=''; |
|
1348 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1349 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1350 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1351 | - |
|
1352 | - $tmparray=dol_getdate($tmpday); |
|
1353 | - $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
|
1354 | - $totalforeachday[$tmpday]+=$dayWorkLoad; |
|
1355 | - |
|
1356 | - $alreadyspent=''; |
|
1357 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1358 | - $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
|
1359 | - |
|
1360 | - global $numstartworkingday, $numendworkingday; |
|
1361 | - $cssweekend=''; |
|
1362 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
1363 | - { |
|
1364 | - $cssweekend='weekend'; |
|
1365 | - } |
|
1366 | - |
|
1367 | - $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1368 | - $placeholder=''; |
|
1369 | - if ($alreadyspent) |
|
1370 | - { |
|
1371 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
1372 | - //$placeholder=' placeholder="00:00"'; |
|
1373 | - //$tableCell.='+'; |
|
1374 | - } |
|
1375 | - $tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"'; |
|
1376 | - $tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
1377 | - $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
1378 | - $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
1379 | - $tableCell.='</td>'; |
|
1380 | - print $tableCell; |
|
1381 | - } |
|
1382 | - |
|
1383 | - // Warning |
|
1384 | - print '<td align="right">'; |
|
1385 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1386 | - else if ($disabledtask) |
|
1387 | - { |
|
1388 | - $titleassigntask = $langs->trans("AssignTaskToMe"); |
|
1389 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
1390 | - |
|
1391 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1392 | - } |
|
1393 | - print '</td>'; |
|
1394 | - |
|
1395 | - print "</tr>\n"; |
|
1396 | - } |
|
1397 | - |
|
1398 | - // Call to show task with a lower level (task under the current task) |
|
1399 | - $inc++; |
|
1400 | - $level++; |
|
1401 | - if ($lines[$i]->id > 0) |
|
1402 | - { |
|
1403 | - //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); |
|
1404 | - //var_dump($totalforeachday); |
|
1405 | - $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); |
|
1406 | - //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
|
1407 | - //var_dump($ret); |
|
1408 | - foreach($ret as $key => $val) |
|
1409 | - { |
|
1410 | - $totalforeachday[$key]+=$val; |
|
1411 | - } |
|
1412 | - //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
|
1413 | - //var_dump($totalforeachday); |
|
1414 | - } |
|
1415 | - $level--; |
|
1416 | - } |
|
1417 | - else |
|
1418 | - { |
|
1419 | - //$level--; |
|
1420 | - } |
|
1421 | - } |
|
1422 | - |
|
1423 | - return $totalforeachday; |
|
1278 | + // Ref |
|
1279 | + print '<td class="nowrap">'; |
|
1280 | + print '<!-- Task id = '.$lines[$i]->id.' -->'; |
|
1281 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1282 | + print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
|
1283 | + // Label task |
|
1284 | + print '<br>'; |
|
1285 | + for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1286 | + //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
|
1287 | + print $taskstatic->label; |
|
1288 | + //print "<br>"; |
|
1289 | + //for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1290 | + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); |
|
1291 | + print "</td>\n"; |
|
1292 | + |
|
1293 | + // Planned Workload |
|
1294 | + print '<td align="right" class="leftborder plannedworkload">'; |
|
1295 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1296 | + else print '--:--'; |
|
1297 | + print '</td>'; |
|
1298 | + |
|
1299 | + // Progress declared % |
|
1300 | + print '<td align="right">'; |
|
1301 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1302 | + print '</td>'; |
|
1303 | + |
|
1304 | + // Time spent by everybody |
|
1305 | + print '<td align="right">'; |
|
1306 | + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user |
|
1307 | + if ($lines[$i]->duration) |
|
1308 | + { |
|
1309 | + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
|
1310 | + print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1311 | + print '</a>'; |
|
1312 | + } |
|
1313 | + else print '--:--'; |
|
1314 | + print "</td>\n"; |
|
1315 | + |
|
1316 | + // Time spent by user |
|
1317 | + print '<td align="right">'; |
|
1318 | + $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1319 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1320 | + else print '--:--'; |
|
1321 | + print "</td>\n"; |
|
1322 | + |
|
1323 | + $disabledproject=1;$disabledtask=1; |
|
1324 | + //print "x".$lines[$i]->fk_project; |
|
1325 | + //var_dump($lines[$i]); |
|
1326 | + //var_dump($projectsrole[$lines[$i]->fk_project]); |
|
1327 | + // If at least one role for project |
|
1328 | + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1329 | + { |
|
1330 | + $disabledproject=0; |
|
1331 | + $disabledtask=0; |
|
1332 | + } |
|
1333 | + // If $restricteditformytask is on and I have no role on task, i disable edit |
|
1334 | + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
|
1335 | + { |
|
1336 | + $disabledtask=1; |
|
1337 | + } |
|
1338 | + |
|
1339 | + //var_dump($projectstatic->weekWorkLoadPerTask); |
|
1340 | + |
|
1341 | + // Fields to show current time |
|
1342 | + $tableCell=''; $modeinput='hours'; |
|
1343 | + for ($idw = 0; $idw < 7; $idw++) |
|
1344 | + { |
|
1345 | + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
1346 | + |
|
1347 | + $cssonholiday=''; |
|
1348 | + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1349 | + elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1350 | + elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1351 | + |
|
1352 | + $tmparray=dol_getdate($tmpday); |
|
1353 | + $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
|
1354 | + $totalforeachday[$tmpday]+=$dayWorkLoad; |
|
1355 | + |
|
1356 | + $alreadyspent=''; |
|
1357 | + if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1358 | + $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
|
1359 | + |
|
1360 | + global $numstartworkingday, $numendworkingday; |
|
1361 | + $cssweekend=''; |
|
1362 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
1363 | + { |
|
1364 | + $cssweekend='weekend'; |
|
1365 | + } |
|
1366 | + |
|
1367 | + $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1368 | + $placeholder=''; |
|
1369 | + if ($alreadyspent) |
|
1370 | + { |
|
1371 | + $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
1372 | + //$placeholder=' placeholder="00:00"'; |
|
1373 | + //$tableCell.='+'; |
|
1374 | + } |
|
1375 | + $tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"'; |
|
1376 | + $tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
1377 | + $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
1378 | + $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
1379 | + $tableCell.='</td>'; |
|
1380 | + print $tableCell; |
|
1381 | + } |
|
1382 | + |
|
1383 | + // Warning |
|
1384 | + print '<td align="right">'; |
|
1385 | + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1386 | + else if ($disabledtask) |
|
1387 | + { |
|
1388 | + $titleassigntask = $langs->trans("AssignTaskToMe"); |
|
1389 | + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
1390 | + |
|
1391 | + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1392 | + } |
|
1393 | + print '</td>'; |
|
1394 | + |
|
1395 | + print "</tr>\n"; |
|
1396 | + } |
|
1397 | + |
|
1398 | + // Call to show task with a lower level (task under the current task) |
|
1399 | + $inc++; |
|
1400 | + $level++; |
|
1401 | + if ($lines[$i]->id > 0) |
|
1402 | + { |
|
1403 | + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); |
|
1404 | + //var_dump($totalforeachday); |
|
1405 | + $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); |
|
1406 | + //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
|
1407 | + //var_dump($ret); |
|
1408 | + foreach($ret as $key => $val) |
|
1409 | + { |
|
1410 | + $totalforeachday[$key]+=$val; |
|
1411 | + } |
|
1412 | + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
|
1413 | + //var_dump($totalforeachday); |
|
1414 | + } |
|
1415 | + $level--; |
|
1416 | + } |
|
1417 | + else |
|
1418 | + { |
|
1419 | + //$level--; |
|
1420 | + } |
|
1421 | + } |
|
1422 | + |
|
1423 | + return $totalforeachday; |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | |
@@ -1435,29 +1435,29 @@ discard block |
||
1435 | 1435 | */ |
1436 | 1436 | function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) |
1437 | 1437 | { |
1438 | - //print 'Search in line with parent id = '.$parent.'<br>'; |
|
1439 | - $numlines=count($lines); |
|
1440 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1441 | - { |
|
1442 | - // Process line $lines[$i] |
|
1443 | - if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) |
|
1444 | - { |
|
1445 | - // If task is legitimate to show, no more need to search deeper |
|
1446 | - if (isset($taskrole[$lines[$i]->id])) |
|
1447 | - { |
|
1448 | - //print 'Found a legitimate task id='.$lines[$i]->id.'<br>'; |
|
1449 | - $inc++; |
|
1450 | - return $inc; |
|
1451 | - } |
|
1452 | - |
|
1453 | - searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); |
|
1454 | - //print 'Found inc='.$inc.'<br>'; |
|
1455 | - |
|
1456 | - if ($inc > 0) return $inc; |
|
1457 | - } |
|
1458 | - } |
|
1459 | - |
|
1460 | - return $inc; |
|
1438 | + //print 'Search in line with parent id = '.$parent.'<br>'; |
|
1439 | + $numlines=count($lines); |
|
1440 | + for ($i = 0 ; $i < $numlines ; $i++) |
|
1441 | + { |
|
1442 | + // Process line $lines[$i] |
|
1443 | + if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) |
|
1444 | + { |
|
1445 | + // If task is legitimate to show, no more need to search deeper |
|
1446 | + if (isset($taskrole[$lines[$i]->id])) |
|
1447 | + { |
|
1448 | + //print 'Found a legitimate task id='.$lines[$i]->id.'<br>'; |
|
1449 | + $inc++; |
|
1450 | + return $inc; |
|
1451 | + } |
|
1452 | + |
|
1453 | + searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); |
|
1454 | + //print 'Found inc='.$inc.'<br>'; |
|
1455 | + |
|
1456 | + if ($inc > 0) return $inc; |
|
1457 | + } |
|
1458 | + } |
|
1459 | + |
|
1460 | + return $inc; |
|
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | /** |
@@ -1475,235 +1475,235 @@ discard block |
||
1475 | 1475 | */ |
1476 | 1476 | function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array()) |
1477 | 1477 | { |
1478 | - global $langs,$conf,$user,$bc; |
|
1479 | - |
|
1480 | - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
1481 | - |
|
1482 | - $projectstatic=new Project($db); |
|
1483 | - $thirdpartystatic=new Societe($db); |
|
1484 | - |
|
1485 | - $sortfield=''; |
|
1486 | - $sortorder=''; |
|
1487 | - $project_year_filter=0; |
|
1488 | - |
|
1489 | - $title=$langs->trans("Projects"); |
|
1490 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
1491 | - |
|
1492 | - $arrayidtypeofcontact=array(); |
|
1493 | - |
|
1494 | - print '<div class="div-table-responsive-no-min">'; |
|
1495 | - print '<table class="noborder" width="100%">'; |
|
1496 | - |
|
1497 | - $sql= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1498 | - if ($mytasks) |
|
1499 | - { |
|
1500 | - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
1501 | - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
1502 | - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
1503 | - } |
|
1504 | - else |
|
1505 | - { |
|
1506 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1507 | - } |
|
1508 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
1509 | - $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
1510 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
1511 | - if ($mytasks) |
|
1512 | - { |
|
1513 | - $sql.= " AND p.rowid = t.fk_projet"; |
|
1514 | - $sql.= " AND ec.element_id = t.rowid"; |
|
1515 | - $sql.= " AND ec.fk_socpeople = ".$user->id; |
|
1516 | - $sql.= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
1517 | - $sql.= " AND ctc.element = 'project_task'"; |
|
1518 | - } |
|
1519 | - if ($statut >= 0) |
|
1520 | - { |
|
1521 | - $sql.= " AND p.fk_statut = ".$statut; |
|
1522 | - } |
|
1523 | - if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
|
1524 | - { |
|
1525 | - $project_year_filter = GETPOST("project_year_filter"); |
|
1526 | - //Check if empty or invalid year. Wildcard ignores the sql check |
|
1527 | - if ($project_year_filter != "*") |
|
1528 | - { |
|
1529 | - if (empty($project_year_filter) || !ctype_digit($project_year_filter)) |
|
1530 | - { |
|
1531 | - $project_year_filter = date("Y"); |
|
1532 | - } |
|
1533 | - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")"; |
|
1534 | - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")"; |
|
1535 | - } |
|
1536 | - } |
|
1537 | - |
|
1538 | - // Get id of project we must show tasks |
|
1539 | - $arrayidofprojects=array(); |
|
1540 | - $sql1 = "SELECT p.rowid as projectid"; |
|
1541 | - $sql1.= $sql; |
|
1542 | - $resql = $db->query($sql1); |
|
1543 | - if ($resql) |
|
1544 | - { |
|
1545 | - $i=0; |
|
1546 | - $num = $db->num_rows($resql); |
|
1547 | - while ($i < $num) |
|
1548 | - { |
|
1549 | - $objp = $db->fetch_object($resql); |
|
1550 | - $arrayidofprojects[$objp->projectid]=$objp->projectid; |
|
1551 | - $i++; |
|
1552 | - } |
|
1553 | - } |
|
1554 | - else dol_print_error($db); |
|
1555 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
1556 | - |
|
1557 | - // Get list of project with calculation on tasks |
|
1558 | - $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; |
|
1559 | - $sql2.= " p.dateo, p.datee,"; |
|
1560 | - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
1561 | - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1562 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
1563 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1564 | - $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; |
|
1565 | - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; |
|
1566 | - $sql2.= " ORDER BY p.title, p.ref"; |
|
1567 | - |
|
1568 | - $resql = $db->query($sql2); |
|
1569 | - if ($resql) |
|
1570 | - { |
|
1571 | - $total_task = 0; |
|
1572 | - $total_opp_amount = 0; |
|
1573 | - $ponderated_opp_amount = 0; |
|
1574 | - |
|
1575 | - $num = $db->num_rows($resql); |
|
1576 | - $i = 0; |
|
1577 | - |
|
1578 | - print '<tr class="liste_titre">'; |
|
1579 | - print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1580 | - print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1581 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1582 | - { |
|
1583 | - print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder); |
|
1584 | - print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder); |
|
1585 | - } |
|
1586 | - if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1587 | - { |
|
1588 | - print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
|
1589 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
1590 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
1591 | - } |
|
1592 | - print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
|
1593 | - print "</tr>\n"; |
|
1594 | - |
|
1595 | - $total_plannedworkload=0; |
|
1596 | - $total_declaredprogressworkload=0; |
|
1597 | - while ($i < $num) |
|
1598 | - { |
|
1599 | - $objp = $db->fetch_object($resql); |
|
1600 | - |
|
1601 | - $projectstatic->id = $objp->projectid; |
|
1602 | - $projectstatic->user_author_id = $objp->fk_user_creat; |
|
1603 | - $projectstatic->public = $objp->public; |
|
1604 | - |
|
1605 | - // Check is user has read permission on project |
|
1606 | - $userAccess = $projectstatic->restrictedProjectArea($user); |
|
1607 | - if ($userAccess >= 0) |
|
1608 | - { |
|
1609 | - $projectstatic->ref=$objp->ref; |
|
1610 | - $projectstatic->statut = $objp->status; |
|
1611 | - $projectstatic->title = $objp->title; |
|
1612 | - $projectstatic->datee = $db->jdate($objp->datee); |
|
1613 | - $projectstatic->dateo = $db->jdate($objp->dateo); |
|
1614 | - |
|
1615 | - |
|
1616 | - print '<tr class="oddeven">'; |
|
1617 | - print '<td>'; |
|
1618 | - print $projectstatic->getNomUrl(1); |
|
1619 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
1620 | - print '</td>'; |
|
1621 | - print '<td>'; |
|
1622 | - if ($objp->fk_soc > 0) |
|
1623 | - { |
|
1624 | - $thirdpartystatic->id=$objp->fk_soc; |
|
1625 | - $thirdpartystatic->ref=$objp->socname; |
|
1626 | - $thirdpartystatic->name=$objp->socname; |
|
1627 | - print $thirdpartystatic->getNomUrl(1); |
|
1628 | - } |
|
1629 | - print '</td>'; |
|
1630 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1631 | - { |
|
1632 | - print '<td align="right">'; |
|
1633 | - if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
1634 | - print '</td>'; |
|
1635 | - print '<td align="right">'; |
|
1636 | - $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); |
|
1637 | - if ($code) print $langs->trans("OppStatus".$code); |
|
1638 | - print '</td>'; |
|
1639 | - } |
|
1640 | - if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1641 | - { |
|
1642 | - print '<td align="right">'.$objp->nb.'</td>'; |
|
1643 | - |
|
1644 | - $plannedworkload=$objp->planned_workload; |
|
1645 | - $total_plannedworkload+=$plannedworkload; |
|
1646 | - if (! in_array('plannedworkload', $hiddenfields)) |
|
1647 | - { |
|
1648 | - print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>'; |
|
1649 | - } |
|
1650 | - if (! in_array('declaredprogress', $hiddenfields)) |
|
1651 | - { |
|
1652 | - $declaredprogressworkload=$objp->declared_progess_workload; |
|
1653 | - $total_declaredprogressworkload+=$declaredprogressworkload; |
|
1654 | - print '<td align="right">'; |
|
1655 | - //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; |
|
1656 | - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':''); |
|
1657 | - print '</td>'; |
|
1658 | - } |
|
1659 | - } |
|
1660 | - |
|
1661 | - print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>'; |
|
1662 | - print "</tr>\n"; |
|
1663 | - |
|
1664 | - $total_task = $total_task + $objp->nb; |
|
1665 | - $total_opp_amount = $total_opp_amount + $objp->opp_amount; |
|
1666 | - $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100); |
|
1667 | - } |
|
1668 | - |
|
1669 | - $i++; |
|
1670 | - } |
|
1671 | - |
|
1672 | - print '<tr class="liste_total">'; |
|
1673 | - print '<td colspan="2">'.$langs->trans("Total")."</td>"; |
|
1674 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1675 | - { |
|
1676 | - print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>'; |
|
1677 | - print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>'; |
|
1678 | - } |
|
1679 | - if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1680 | - { |
|
1681 | - print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
|
1682 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
1683 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
1684 | - } |
|
1685 | - print '<td class="liste_total"></td>'; |
|
1686 | - print '</tr>'; |
|
1687 | - |
|
1688 | - $db->free($resql); |
|
1689 | - } |
|
1690 | - else |
|
1691 | - { |
|
1692 | - dol_print_error($db); |
|
1693 | - } |
|
1694 | - |
|
1695 | - print "</table>"; |
|
1696 | - print '</div>'; |
|
1697 | - |
|
1698 | - if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
|
1699 | - { |
|
1700 | - //Add the year filter input |
|
1701 | - print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'; |
|
1702 | - print '<table width="100%">'; |
|
1703 | - print '<tr>'; |
|
1704 | - print '<td>'.$langs->trans("Year").'</td>'; |
|
1705 | - print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.'"/>'; |
|
1706 | - print "</tr>\n"; |
|
1707 | - print '</table></form>'; |
|
1708 | - } |
|
1478 | + global $langs,$conf,$user,$bc; |
|
1479 | + |
|
1480 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
1481 | + |
|
1482 | + $projectstatic=new Project($db); |
|
1483 | + $thirdpartystatic=new Societe($db); |
|
1484 | + |
|
1485 | + $sortfield=''; |
|
1486 | + $sortorder=''; |
|
1487 | + $project_year_filter=0; |
|
1488 | + |
|
1489 | + $title=$langs->trans("Projects"); |
|
1490 | + if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
1491 | + |
|
1492 | + $arrayidtypeofcontact=array(); |
|
1493 | + |
|
1494 | + print '<div class="div-table-responsive-no-min">'; |
|
1495 | + print '<table class="noborder" width="100%">'; |
|
1496 | + |
|
1497 | + $sql= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1498 | + if ($mytasks) |
|
1499 | + { |
|
1500 | + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
1501 | + $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
1502 | + $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
1503 | + } |
|
1504 | + else |
|
1505 | + { |
|
1506 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1507 | + } |
|
1508 | + $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
1509 | + $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
1510 | + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
1511 | + if ($mytasks) |
|
1512 | + { |
|
1513 | + $sql.= " AND p.rowid = t.fk_projet"; |
|
1514 | + $sql.= " AND ec.element_id = t.rowid"; |
|
1515 | + $sql.= " AND ec.fk_socpeople = ".$user->id; |
|
1516 | + $sql.= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
1517 | + $sql.= " AND ctc.element = 'project_task'"; |
|
1518 | + } |
|
1519 | + if ($statut >= 0) |
|
1520 | + { |
|
1521 | + $sql.= " AND p.fk_statut = ".$statut; |
|
1522 | + } |
|
1523 | + if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
|
1524 | + { |
|
1525 | + $project_year_filter = GETPOST("project_year_filter"); |
|
1526 | + //Check if empty or invalid year. Wildcard ignores the sql check |
|
1527 | + if ($project_year_filter != "*") |
|
1528 | + { |
|
1529 | + if (empty($project_year_filter) || !ctype_digit($project_year_filter)) |
|
1530 | + { |
|
1531 | + $project_year_filter = date("Y"); |
|
1532 | + } |
|
1533 | + $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")"; |
|
1534 | + $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")"; |
|
1535 | + } |
|
1536 | + } |
|
1537 | + |
|
1538 | + // Get id of project we must show tasks |
|
1539 | + $arrayidofprojects=array(); |
|
1540 | + $sql1 = "SELECT p.rowid as projectid"; |
|
1541 | + $sql1.= $sql; |
|
1542 | + $resql = $db->query($sql1); |
|
1543 | + if ($resql) |
|
1544 | + { |
|
1545 | + $i=0; |
|
1546 | + $num = $db->num_rows($resql); |
|
1547 | + while ($i < $num) |
|
1548 | + { |
|
1549 | + $objp = $db->fetch_object($resql); |
|
1550 | + $arrayidofprojects[$objp->projectid]=$objp->projectid; |
|
1551 | + $i++; |
|
1552 | + } |
|
1553 | + } |
|
1554 | + else dol_print_error($db); |
|
1555 | + if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
1556 | + |
|
1557 | + // Get list of project with calculation on tasks |
|
1558 | + $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; |
|
1559 | + $sql2.= " p.dateo, p.datee,"; |
|
1560 | + $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
1561 | + $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1562 | + $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
1563 | + $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1564 | + $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; |
|
1565 | + $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; |
|
1566 | + $sql2.= " ORDER BY p.title, p.ref"; |
|
1567 | + |
|
1568 | + $resql = $db->query($sql2); |
|
1569 | + if ($resql) |
|
1570 | + { |
|
1571 | + $total_task = 0; |
|
1572 | + $total_opp_amount = 0; |
|
1573 | + $ponderated_opp_amount = 0; |
|
1574 | + |
|
1575 | + $num = $db->num_rows($resql); |
|
1576 | + $i = 0; |
|
1577 | + |
|
1578 | + print '<tr class="liste_titre">'; |
|
1579 | + print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1580 | + print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1581 | + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1582 | + { |
|
1583 | + print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder); |
|
1584 | + print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder); |
|
1585 | + } |
|
1586 | + if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1587 | + { |
|
1588 | + print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
|
1589 | + if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
1590 | + if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
1591 | + } |
|
1592 | + print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
|
1593 | + print "</tr>\n"; |
|
1594 | + |
|
1595 | + $total_plannedworkload=0; |
|
1596 | + $total_declaredprogressworkload=0; |
|
1597 | + while ($i < $num) |
|
1598 | + { |
|
1599 | + $objp = $db->fetch_object($resql); |
|
1600 | + |
|
1601 | + $projectstatic->id = $objp->projectid; |
|
1602 | + $projectstatic->user_author_id = $objp->fk_user_creat; |
|
1603 | + $projectstatic->public = $objp->public; |
|
1604 | + |
|
1605 | + // Check is user has read permission on project |
|
1606 | + $userAccess = $projectstatic->restrictedProjectArea($user); |
|
1607 | + if ($userAccess >= 0) |
|
1608 | + { |
|
1609 | + $projectstatic->ref=$objp->ref; |
|
1610 | + $projectstatic->statut = $objp->status; |
|
1611 | + $projectstatic->title = $objp->title; |
|
1612 | + $projectstatic->datee = $db->jdate($objp->datee); |
|
1613 | + $projectstatic->dateo = $db->jdate($objp->dateo); |
|
1614 | + |
|
1615 | + |
|
1616 | + print '<tr class="oddeven">'; |
|
1617 | + print '<td>'; |
|
1618 | + print $projectstatic->getNomUrl(1); |
|
1619 | + if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
1620 | + print '</td>'; |
|
1621 | + print '<td>'; |
|
1622 | + if ($objp->fk_soc > 0) |
|
1623 | + { |
|
1624 | + $thirdpartystatic->id=$objp->fk_soc; |
|
1625 | + $thirdpartystatic->ref=$objp->socname; |
|
1626 | + $thirdpartystatic->name=$objp->socname; |
|
1627 | + print $thirdpartystatic->getNomUrl(1); |
|
1628 | + } |
|
1629 | + print '</td>'; |
|
1630 | + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1631 | + { |
|
1632 | + print '<td align="right">'; |
|
1633 | + if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
1634 | + print '</td>'; |
|
1635 | + print '<td align="right">'; |
|
1636 | + $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); |
|
1637 | + if ($code) print $langs->trans("OppStatus".$code); |
|
1638 | + print '</td>'; |
|
1639 | + } |
|
1640 | + if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1641 | + { |
|
1642 | + print '<td align="right">'.$objp->nb.'</td>'; |
|
1643 | + |
|
1644 | + $plannedworkload=$objp->planned_workload; |
|
1645 | + $total_plannedworkload+=$plannedworkload; |
|
1646 | + if (! in_array('plannedworkload', $hiddenfields)) |
|
1647 | + { |
|
1648 | + print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>'; |
|
1649 | + } |
|
1650 | + if (! in_array('declaredprogress', $hiddenfields)) |
|
1651 | + { |
|
1652 | + $declaredprogressworkload=$objp->declared_progess_workload; |
|
1653 | + $total_declaredprogressworkload+=$declaredprogressworkload; |
|
1654 | + print '<td align="right">'; |
|
1655 | + //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; |
|
1656 | + print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':''); |
|
1657 | + print '</td>'; |
|
1658 | + } |
|
1659 | + } |
|
1660 | + |
|
1661 | + print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>'; |
|
1662 | + print "</tr>\n"; |
|
1663 | + |
|
1664 | + $total_task = $total_task + $objp->nb; |
|
1665 | + $total_opp_amount = $total_opp_amount + $objp->opp_amount; |
|
1666 | + $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100); |
|
1667 | + } |
|
1668 | + |
|
1669 | + $i++; |
|
1670 | + } |
|
1671 | + |
|
1672 | + print '<tr class="liste_total">'; |
|
1673 | + print '<td colspan="2">'.$langs->trans("Total")."</td>"; |
|
1674 | + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1675 | + { |
|
1676 | + print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>'; |
|
1677 | + print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>'; |
|
1678 | + } |
|
1679 | + if (empty($conf->global->PROJECT_HIDE_TASKS)) |
|
1680 | + { |
|
1681 | + print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
|
1682 | + if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
1683 | + if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
1684 | + } |
|
1685 | + print '<td class="liste_total"></td>'; |
|
1686 | + print '</tr>'; |
|
1687 | + |
|
1688 | + $db->free($resql); |
|
1689 | + } |
|
1690 | + else |
|
1691 | + { |
|
1692 | + dol_print_error($db); |
|
1693 | + } |
|
1694 | + |
|
1695 | + print "</table>"; |
|
1696 | + print '</div>'; |
|
1697 | + |
|
1698 | + if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
|
1699 | + { |
|
1700 | + //Add the year filter input |
|
1701 | + print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'; |
|
1702 | + print '<table width="100%">'; |
|
1703 | + print '<tr>'; |
|
1704 | + print '<td>'.$langs->trans("Year").'</td>'; |
|
1705 | + print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.'"/>'; |
|
1706 | + print "</tr>\n"; |
|
1707 | + print '</table></form>'; |
|
1708 | + } |
|
1709 | 1709 | } |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | |
26 | 26 | if (! function_exists('json_encode')) |
27 | 27 | { |
28 | - /** |
|
29 | - * Implement json_encode for PHP that does not have module enabled. |
|
30 | - * |
|
31 | - * @param mixed $elements PHP Object to json encode |
|
32 | - * @return string Json encoded string |
|
33 | - */ |
|
34 | - function json_encode($elements) |
|
35 | - { |
|
36 | - return dol_json_encode($elements); |
|
37 | - } |
|
28 | + /** |
|
29 | + * Implement json_encode for PHP that does not have module enabled. |
|
30 | + * |
|
31 | + * @param mixed $elements PHP Object to json encode |
|
32 | + * @return string Json encoded string |
|
33 | + */ |
|
34 | + function json_encode($elements) |
|
35 | + { |
|
36 | + return dol_json_encode($elements); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -47,56 +47,56 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function dol_json_encode($elements) |
49 | 49 | { |
50 | - dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
|
51 | - |
|
52 | - $num=0; |
|
53 | - if (is_object($elements)) // Count number of properties for an object |
|
54 | - { |
|
55 | - foreach($elements as $key => $value) $num++; |
|
56 | - } |
|
57 | - else |
|
58 | - { |
|
59 | - $num=count($elements); |
|
60 | - } |
|
61 | - //var_dump($num); |
|
62 | - |
|
63 | - // determine type |
|
64 | - if (is_numeric(key($elements)) && key($elements) == 0) |
|
65 | - { |
|
66 | - // indexed (list) |
|
67 | - $keysofelements=array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. |
|
68 | - $output = '['; |
|
69 | - for ($i = 0, $last = ($num - 1); $i < $num; $i++) |
|
70 | - { |
|
71 | - if (! isset($elements[$keysofelements[$i]])) continue; |
|
72 | - if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]); |
|
73 | - else $output .= _val($elements[$keysofelements[$i]]); |
|
74 | - if ($i !== $last) $output.= ','; |
|
75 | - } |
|
76 | - $output.= ']'; |
|
77 | - } |
|
78 | - else |
|
79 | - { |
|
80 | - // associative (object) |
|
81 | - $output = '{'; |
|
82 | - $last = $num - 1; |
|
83 | - $i = 0; |
|
84 | - $tmpelements=array(); |
|
85 | - if (is_array($elements)) $tmpelements=$elements; |
|
86 | - if (is_object($elements)) $tmpelements=get_object_vars($elements); |
|
87 | - foreach($tmpelements as $key => $value) |
|
88 | - { |
|
89 | - $output .= '"'.$key.'":'; |
|
90 | - if (is_array($value)) $output.= json_encode($value); |
|
91 | - else $output .= _val($value); |
|
92 | - if ($i !== $last) $output.= ','; |
|
93 | - ++$i; |
|
94 | - } |
|
95 | - $output.= '}'; |
|
96 | - } |
|
97 | - |
|
98 | - // return |
|
99 | - return $output; |
|
50 | + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
|
51 | + |
|
52 | + $num=0; |
|
53 | + if (is_object($elements)) // Count number of properties for an object |
|
54 | + { |
|
55 | + foreach($elements as $key => $value) $num++; |
|
56 | + } |
|
57 | + else |
|
58 | + { |
|
59 | + $num=count($elements); |
|
60 | + } |
|
61 | + //var_dump($num); |
|
62 | + |
|
63 | + // determine type |
|
64 | + if (is_numeric(key($elements)) && key($elements) == 0) |
|
65 | + { |
|
66 | + // indexed (list) |
|
67 | + $keysofelements=array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. |
|
68 | + $output = '['; |
|
69 | + for ($i = 0, $last = ($num - 1); $i < $num; $i++) |
|
70 | + { |
|
71 | + if (! isset($elements[$keysofelements[$i]])) continue; |
|
72 | + if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]); |
|
73 | + else $output .= _val($elements[$keysofelements[$i]]); |
|
74 | + if ($i !== $last) $output.= ','; |
|
75 | + } |
|
76 | + $output.= ']'; |
|
77 | + } |
|
78 | + else |
|
79 | + { |
|
80 | + // associative (object) |
|
81 | + $output = '{'; |
|
82 | + $last = $num - 1; |
|
83 | + $i = 0; |
|
84 | + $tmpelements=array(); |
|
85 | + if (is_array($elements)) $tmpelements=$elements; |
|
86 | + if (is_object($elements)) $tmpelements=get_object_vars($elements); |
|
87 | + foreach($tmpelements as $key => $value) |
|
88 | + { |
|
89 | + $output .= '"'.$key.'":'; |
|
90 | + if (is_array($value)) $output.= json_encode($value); |
|
91 | + else $output .= _val($value); |
|
92 | + if ($i !== $last) $output.= ','; |
|
93 | + ++$i; |
|
94 | + } |
|
95 | + $output.= '}'; |
|
96 | + } |
|
97 | + |
|
98 | + // return |
|
99 | + return $output; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function _val($val) |
109 | 109 | { |
110 | - if (is_string($val)) |
|
111 | - { |
|
110 | + if (is_string($val)) |
|
111 | + { |
|
112 | 112 | // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT |
113 | 113 | $ascii = ''; |
114 | 114 | $strlen_var = strlen($val); |
@@ -117,107 +117,107 @@ discard block |
||
117 | 117 | * Iterate over every character in the string, |
118 | 118 | * escaping with a slash or encoding to UTF-8 where necessary |
119 | 119 | */ |
120 | - for ($c = 0; $c < $strlen_var; ++$c) { |
|
121 | - |
|
122 | - $ord_var_c = ord($val{$c}); |
|
123 | - |
|
124 | - switch (true) { |
|
125 | - case $ord_var_c == 0x08: |
|
126 | - $ascii .= '\b'; |
|
127 | - break; |
|
128 | - case $ord_var_c == 0x09: |
|
129 | - $ascii .= '\t'; |
|
130 | - break; |
|
131 | - case $ord_var_c == 0x0A: |
|
132 | - $ascii .= '\n'; |
|
133 | - break; |
|
134 | - case $ord_var_c == 0x0C: |
|
135 | - $ascii .= '\f'; |
|
136 | - break; |
|
137 | - case $ord_var_c == 0x0D: |
|
138 | - $ascii .= '\r'; |
|
139 | - break; |
|
140 | - |
|
141 | - case $ord_var_c == 0x22: |
|
142 | - case $ord_var_c == 0x2F: |
|
143 | - case $ord_var_c == 0x5C: |
|
144 | - // double quote, slash, slosh |
|
145 | - $ascii .= '\\'.$val{$c}; |
|
146 | - break; |
|
147 | - |
|
148 | - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
|
149 | - // characters U-00000000 - U-0000007F (same as ASCII) |
|
150 | - $ascii .= $val{$c}; |
|
151 | - break; |
|
152 | - |
|
153 | - case (($ord_var_c & 0xE0) == 0xC0): |
|
154 | - // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
155 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
156 | - $char = pack('C*', $ord_var_c, ord($val{$c + 1})); |
|
157 | - $c += 1; |
|
158 | - $utf16 = utf82utf16($char); |
|
159 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
160 | - break; |
|
161 | - |
|
162 | - case (($ord_var_c & 0xF0) == 0xE0): |
|
163 | - // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
164 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
165 | - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2})); |
|
166 | - $c += 2; |
|
167 | - $utf16 = utf82utf16($char); |
|
168 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
169 | - break; |
|
170 | - |
|
171 | - case (($ord_var_c & 0xF8) == 0xF0): |
|
172 | - // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
173 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
174 | - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3})); |
|
175 | - $c += 3; |
|
176 | - $utf16 = utf82utf16($char); |
|
177 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
178 | - break; |
|
179 | - |
|
180 | - case (($ord_var_c & 0xFC) == 0xF8): |
|
181 | - // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
182 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
183 | - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4})); |
|
184 | - $c += 4; |
|
185 | - $utf16 = utf82utf16($char); |
|
186 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
187 | - break; |
|
188 | - |
|
189 | - case (($ord_var_c & 0xFE) == 0xFC): |
|
190 | - // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
191 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
192 | - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4}), ord($val{$c + 5})); |
|
193 | - $c += 5; |
|
194 | - $utf16 = utf82utf16($char); |
|
195 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
196 | - break; |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - return '"'.$ascii.'"'; |
|
201 | - } |
|
202 | - elseif (is_int($val)) return sprintf('%d', $val); |
|
203 | - elseif (is_float($val)) return sprintf('%F', $val); |
|
204 | - elseif (is_bool($val)) return ($val ? 'true' : 'false'); |
|
205 | - else return 'null'; |
|
120 | + for ($c = 0; $c < $strlen_var; ++$c) { |
|
121 | + |
|
122 | + $ord_var_c = ord($val{$c}); |
|
123 | + |
|
124 | + switch (true) { |
|
125 | + case $ord_var_c == 0x08: |
|
126 | + $ascii .= '\b'; |
|
127 | + break; |
|
128 | + case $ord_var_c == 0x09: |
|
129 | + $ascii .= '\t'; |
|
130 | + break; |
|
131 | + case $ord_var_c == 0x0A: |
|
132 | + $ascii .= '\n'; |
|
133 | + break; |
|
134 | + case $ord_var_c == 0x0C: |
|
135 | + $ascii .= '\f'; |
|
136 | + break; |
|
137 | + case $ord_var_c == 0x0D: |
|
138 | + $ascii .= '\r'; |
|
139 | + break; |
|
140 | + |
|
141 | + case $ord_var_c == 0x22: |
|
142 | + case $ord_var_c == 0x2F: |
|
143 | + case $ord_var_c == 0x5C: |
|
144 | + // double quote, slash, slosh |
|
145 | + $ascii .= '\\'.$val{$c}; |
|
146 | + break; |
|
147 | + |
|
148 | + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
|
149 | + // characters U-00000000 - U-0000007F (same as ASCII) |
|
150 | + $ascii .= $val{$c}; |
|
151 | + break; |
|
152 | + |
|
153 | + case (($ord_var_c & 0xE0) == 0xC0): |
|
154 | + // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
155 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
156 | + $char = pack('C*', $ord_var_c, ord($val{$c + 1})); |
|
157 | + $c += 1; |
|
158 | + $utf16 = utf82utf16($char); |
|
159 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
160 | + break; |
|
161 | + |
|
162 | + case (($ord_var_c & 0xF0) == 0xE0): |
|
163 | + // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
164 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
165 | + $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2})); |
|
166 | + $c += 2; |
|
167 | + $utf16 = utf82utf16($char); |
|
168 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
169 | + break; |
|
170 | + |
|
171 | + case (($ord_var_c & 0xF8) == 0xF0): |
|
172 | + // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
173 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
174 | + $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3})); |
|
175 | + $c += 3; |
|
176 | + $utf16 = utf82utf16($char); |
|
177 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
178 | + break; |
|
179 | + |
|
180 | + case (($ord_var_c & 0xFC) == 0xF8): |
|
181 | + // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
182 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
183 | + $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4})); |
|
184 | + $c += 4; |
|
185 | + $utf16 = utf82utf16($char); |
|
186 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
187 | + break; |
|
188 | + |
|
189 | + case (($ord_var_c & 0xFE) == 0xFC): |
|
190 | + // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
191 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
192 | + $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4}), ord($val{$c + 5})); |
|
193 | + $c += 5; |
|
194 | + $utf16 = utf82utf16($char); |
|
195 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
196 | + break; |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + return '"'.$ascii.'"'; |
|
201 | + } |
|
202 | + elseif (is_int($val)) return sprintf('%d', $val); |
|
203 | + elseif (is_float($val)) return sprintf('%F', $val); |
|
204 | + elseif (is_bool($val)) return ($val ? 'true' : 'false'); |
|
205 | + else return 'null'; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | if (! function_exists('json_decode')) |
209 | 209 | { |
210 | - /** |
|
211 | - * Implement json_decode for PHP that does not support it |
|
212 | - * |
|
213 | - * @param string $json Json encoded to PHP Object or Array |
|
214 | - * @param bool $assoc False return an object, true return an array |
|
215 | - * @return mixed Object or Array |
|
216 | - */ |
|
217 | - function json_decode($json, $assoc=false) |
|
218 | - { |
|
219 | - return dol_json_decode($json, $assoc); |
|
220 | - } |
|
210 | + /** |
|
211 | + * Implement json_decode for PHP that does not support it |
|
212 | + * |
|
213 | + * @param string $json Json encoded to PHP Object or Array |
|
214 | + * @param bool $assoc False return an object, true return an array |
|
215 | + * @return mixed Object or Array |
|
216 | + */ |
|
217 | + function json_decode($json, $assoc=false) |
|
218 | + { |
|
219 | + return dol_json_decode($json, $assoc); |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -231,52 +231,52 @@ discard block |
||
231 | 231 | */ |
232 | 232 | function dol_json_decode($json, $assoc=false) |
233 | 233 | { |
234 | - dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
|
234 | + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
|
235 | 235 | |
236 | - $comment = false; |
|
236 | + $comment = false; |
|
237 | 237 | |
238 | 238 | $out=''; |
239 | - $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length |
|
240 | - for ($i=0; $i<$strLength; $i++) |
|
241 | - { |
|
242 | - if (! $comment) |
|
243 | - { |
|
244 | - if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; |
|
245 | - else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; |
|
246 | - else if ($json[$i] == ':') $out.= ' => '; |
|
247 | - else $out.=$json[$i]; |
|
248 | - } |
|
249 | - else $out.= $json[$i]; |
|
250 | - if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; |
|
251 | - } |
|
252 | - |
|
253 | - $out=_unval($out); |
|
254 | - |
|
255 | - // Return an array |
|
256 | - if ($out != '') eval('$array = '.$out.';'); |
|
257 | - else $array=array(); |
|
258 | - |
|
259 | - // Return an object |
|
260 | - if (! $assoc) |
|
261 | - { |
|
262 | - if (! empty($array)) |
|
263 | - { |
|
264 | - $object = false; |
|
265 | - if (count($array)>0) { |
|
266 | - $object = (object) array(); |
|
267 | - } |
|
268 | - foreach ($array as $key => $value) |
|
269 | - { |
|
270 | - if ($key) $object->{$key} = $value; |
|
271 | - } |
|
272 | - |
|
273 | - return $object; |
|
274 | - } |
|
275 | - |
|
276 | - return false; |
|
277 | - } |
|
278 | - |
|
279 | - return $array; |
|
239 | + $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length |
|
240 | + for ($i=0; $i<$strLength; $i++) |
|
241 | + { |
|
242 | + if (! $comment) |
|
243 | + { |
|
244 | + if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; |
|
245 | + else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; |
|
246 | + else if ($json[$i] == ':') $out.= ' => '; |
|
247 | + else $out.=$json[$i]; |
|
248 | + } |
|
249 | + else $out.= $json[$i]; |
|
250 | + if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; |
|
251 | + } |
|
252 | + |
|
253 | + $out=_unval($out); |
|
254 | + |
|
255 | + // Return an array |
|
256 | + if ($out != '') eval('$array = '.$out.';'); |
|
257 | + else $array=array(); |
|
258 | + |
|
259 | + // Return an object |
|
260 | + if (! $assoc) |
|
261 | + { |
|
262 | + if (! empty($array)) |
|
263 | + { |
|
264 | + $object = false; |
|
265 | + if (count($array)>0) { |
|
266 | + $object = (object) array(); |
|
267 | + } |
|
268 | + foreach ($array as $key => $value) |
|
269 | + { |
|
270 | + if ($key) $object->{$key} = $value; |
|
271 | + } |
|
272 | + |
|
273 | + return $object; |
|
274 | + } |
|
275 | + |
|
276 | + return false; |
|
277 | + } |
|
278 | + |
|
279 | + return $array; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function _unval($val) |
289 | 289 | { |
290 | - while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) |
|
291 | - { |
|
292 | - // single, escaped unicode character |
|
293 | - $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); |
|
294 | - $utf8 = utf162utf8($utf16); |
|
295 | - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); |
|
296 | - } |
|
297 | - return $val; |
|
290 | + while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) |
|
291 | + { |
|
292 | + // single, escaped unicode character |
|
293 | + $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); |
|
294 | + $utf8 = utf162utf8($utf16); |
|
295 | + $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); |
|
296 | + } |
|
297 | + return $val; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -309,35 +309,35 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function utf162utf8($utf16) |
311 | 311 | { |
312 | - // oh please oh please oh please oh please oh please |
|
313 | - if(function_exists('mb_convert_encoding')) { |
|
314 | - return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); |
|
315 | - } |
|
316 | - |
|
317 | - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); |
|
318 | - |
|
319 | - switch(true) { |
|
320 | - case ((0x7F & $bytes) == $bytes): |
|
321 | - // this case should never be reached, because we are in ASCII range |
|
322 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
323 | - return chr($bytes); |
|
324 | - |
|
325 | - case (0x07FF & $bytes) == $bytes: |
|
326 | - // return a 2-byte UTF-8 character |
|
327 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
328 | - return chr(0xC0 | (($bytes >> 6) & 0x1F)) |
|
329 | - . chr(0x80 | ($bytes & 0x3F)); |
|
330 | - |
|
331 | - case (0xFFFF & $bytes) == $bytes: |
|
332 | - // return a 3-byte UTF-8 character |
|
333 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
334 | - return chr(0xE0 | (($bytes >> 12) & 0x0F)) |
|
335 | - . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
336 | - . chr(0x80 | ($bytes & 0x3F)); |
|
337 | - } |
|
338 | - |
|
339 | - // ignoring UTF-32 for now, sorry |
|
340 | - return ''; |
|
312 | + // oh please oh please oh please oh please oh please |
|
313 | + if(function_exists('mb_convert_encoding')) { |
|
314 | + return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); |
|
315 | + } |
|
316 | + |
|
317 | + $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); |
|
318 | + |
|
319 | + switch(true) { |
|
320 | + case ((0x7F & $bytes) == $bytes): |
|
321 | + // this case should never be reached, because we are in ASCII range |
|
322 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
323 | + return chr($bytes); |
|
324 | + |
|
325 | + case (0x07FF & $bytes) == $bytes: |
|
326 | + // return a 2-byte UTF-8 character |
|
327 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
328 | + return chr(0xC0 | (($bytes >> 6) & 0x1F)) |
|
329 | + . chr(0x80 | ($bytes & 0x3F)); |
|
330 | + |
|
331 | + case (0xFFFF & $bytes) == $bytes: |
|
332 | + // return a 3-byte UTF-8 character |
|
333 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
334 | + return chr(0xE0 | (($bytes >> 12) & 0x0F)) |
|
335 | + . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
336 | + . chr(0x80 | ($bytes & 0x3F)); |
|
337 | + } |
|
338 | + |
|
339 | + // ignoring UTF-32 for now, sorry |
|
340 | + return ''; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -352,28 +352,28 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function utf82utf16($utf8) |
354 | 354 | { |
355 | - // oh please oh please oh please oh please oh please |
|
356 | - if(function_exists('mb_convert_encoding')) { |
|
357 | - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
|
358 | - } |
|
359 | - |
|
360 | - switch(strlen($utf8)) { |
|
361 | - case 1: |
|
362 | - // this case should never be reached, because we are in ASCII range |
|
363 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
364 | - return $utf8; |
|
365 | - |
|
366 | - case 2: |
|
367 | - // return a UTF-16 character from a 2-byte UTF-8 char |
|
368 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
369 | - return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); |
|
370 | - |
|
371 | - case 3: |
|
372 | - // return a UTF-16 character from a 3-byte UTF-8 char |
|
373 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
374 | - return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); |
|
375 | - } |
|
376 | - |
|
377 | - // ignoring UTF-32 for now, sorry |
|
378 | - return ''; |
|
355 | + // oh please oh please oh please oh please oh please |
|
356 | + if(function_exists('mb_convert_encoding')) { |
|
357 | + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
|
358 | + } |
|
359 | + |
|
360 | + switch(strlen($utf8)) { |
|
361 | + case 1: |
|
362 | + // this case should never be reached, because we are in ASCII range |
|
363 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
364 | + return $utf8; |
|
365 | + |
|
366 | + case 2: |
|
367 | + // return a UTF-16 character from a 2-byte UTF-8 char |
|
368 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
369 | + return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); |
|
370 | + |
|
371 | + case 3: |
|
372 | + // return a UTF-16 character from a 3-byte UTF-8 char |
|
373 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
374 | + return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); |
|
375 | + } |
|
376 | + |
|
377 | + // ignoring UTF-32 for now, sorry |
|
378 | + return ''; |
|
379 | 379 | } |
@@ -40,129 +40,129 @@ |
||
40 | 40 | */ |
41 | 41 | function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0) |
42 | 42 | { |
43 | - global $db, $conf, $langs; |
|
43 | + global $db, $conf, $langs; |
|
44 | 44 | |
45 | - $idprod=$line->fk_product; |
|
46 | - $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); |
|
47 | - $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); |
|
48 | - $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
49 | - $note=(! empty($line->note)?$line->note:''); |
|
45 | + $idprod=$line->fk_product; |
|
46 | + $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); |
|
47 | + $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); |
|
48 | + $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
49 | + $note=(! empty($line->note)?$line->note:''); |
|
50 | 50 | |
51 | - if ($issupplierline) $prodser = new ProductFournisseur($db); |
|
52 | - else $prodser = new Product($db); |
|
51 | + if ($issupplierline) $prodser = new ProductFournisseur($db); |
|
52 | + else $prodser = new Product($db); |
|
53 | 53 | |
54 | - if ($idprod) |
|
55 | - { |
|
56 | - $prodser->fetch($idprod); |
|
57 | - // If a predefined product and multilang and on other lang, we renamed label with label translated |
|
58 | - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
59 | - { |
|
60 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
61 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
62 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
63 | - } |
|
64 | - } |
|
54 | + if ($idprod) |
|
55 | + { |
|
56 | + $prodser->fetch($idprod); |
|
57 | + // If a predefined product and multilang and on other lang, we renamed label with label translated |
|
58 | + if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
59 | + { |
|
60 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
61 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
62 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - // Description short of product line |
|
67 | - $libelleproduitservice=$label; |
|
66 | + // Description short of product line |
|
67 | + $libelleproduitservice=$label; |
|
68 | 68 | |
69 | - // Description long of product line |
|
70 | - if ($desc && ($desc != $label)) |
|
71 | - { |
|
72 | - if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) |
|
73 | - { |
|
74 | - $discount=new DiscountAbsolute($db); |
|
75 | - $discount->fetch($line->fk_remise_except); |
|
76 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
77 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
|
78 | - } |
|
79 | - elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) |
|
80 | - { |
|
81 | - $discount=new DiscountAbsolute($db); |
|
82 | - $discount->fetch($line->fk_remise_except); |
|
83 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
84 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
|
85 | - // Add date of deposit |
|
86 | - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
87 | - } |
|
88 | - elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) |
|
89 | - { |
|
90 | - $discount=new DiscountAbsolute($db); |
|
91 | - $discount->fetch($line->fk_remise_except); |
|
92 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
|
93 | - } |
|
94 | - elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) |
|
95 | - { |
|
96 | - $discount=new DiscountAbsolute($db); |
|
97 | - $discount->fetch($line->fk_remise_except); |
|
98 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - if ($idprod) |
|
103 | - { |
|
104 | - if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
105 | - } |
|
106 | - else |
|
107 | - { |
|
108 | - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
69 | + // Description long of product line |
|
70 | + if ($desc && ($desc != $label)) |
|
71 | + { |
|
72 | + if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) |
|
73 | + { |
|
74 | + $discount=new DiscountAbsolute($db); |
|
75 | + $discount->fetch($line->fk_remise_except); |
|
76 | + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
77 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
|
78 | + } |
|
79 | + elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) |
|
80 | + { |
|
81 | + $discount=new DiscountAbsolute($db); |
|
82 | + $discount->fetch($line->fk_remise_except); |
|
83 | + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
84 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
|
85 | + // Add date of deposit |
|
86 | + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
87 | + } |
|
88 | + elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) |
|
89 | + { |
|
90 | + $discount=new DiscountAbsolute($db); |
|
91 | + $discount->fetch($line->fk_remise_except); |
|
92 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
|
93 | + } |
|
94 | + elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) |
|
95 | + { |
|
96 | + $discount=new DiscountAbsolute($db); |
|
97 | + $discount->fetch($line->fk_remise_except); |
|
98 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + if ($idprod) |
|
103 | + { |
|
104 | + if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
105 | + } |
|
106 | + else |
|
107 | + { |
|
108 | + $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - // If line linked to a product |
|
114 | - if ($idprod) |
|
115 | - { |
|
116 | - // On ajoute la ref |
|
117 | - if ($prodser->ref) |
|
118 | - { |
|
119 | - $prefix_prodserv = ""; |
|
120 | - $ref_prodserv = ""; |
|
121 | - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
122 | - { |
|
123 | - if ($prodser->isService()) |
|
124 | - { |
|
125 | - $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
|
130 | - } |
|
131 | - } |
|
113 | + // If line linked to a product |
|
114 | + if ($idprod) |
|
115 | + { |
|
116 | + // On ajoute la ref |
|
117 | + if ($prodser->ref) |
|
118 | + { |
|
119 | + $prefix_prodserv = ""; |
|
120 | + $ref_prodserv = ""; |
|
121 | + if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
122 | + { |
|
123 | + if ($prodser->isService()) |
|
124 | + { |
|
125 | + $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - if (empty($hideref)) |
|
134 | - { |
|
135 | - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref |
|
136 | - else $ref_prodserv = $prodser->ref; // Show local ref only |
|
133 | + if (empty($hideref)) |
|
134 | + { |
|
135 | + if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref |
|
136 | + else $ref_prodserv = $prodser->ref; // Show local ref only |
|
137 | 137 | |
138 | - $ref_prodserv .= " - "; |
|
139 | - } |
|
138 | + $ref_prodserv .= " - "; |
|
139 | + } |
|
140 | 140 | |
141 | - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
142 | - } |
|
143 | - } |
|
141 | + $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - if (! empty($line->date_start) || ! empty($line->date_end)) |
|
146 | - { |
|
147 | - $format='day'; |
|
148 | - // Show duration if exists |
|
149 | - if ($line->date_start && $line->date_end) |
|
150 | - { |
|
151 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($line->date_start, $format, false, $outputlangs),dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
152 | - } |
|
153 | - if ($line->date_start && ! $line->date_end) |
|
154 | - { |
|
155 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($line->date_start, $format, false, $outputlangs)).')'; |
|
156 | - } |
|
157 | - if (! $line->date_start && $line->date_end) |
|
158 | - { |
|
159 | - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
160 | - } |
|
161 | - //print '>'.$outputlangs->charset_output.','.$period; |
|
162 | - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $period); |
|
163 | - //print $libelleproduitservice; |
|
164 | - } |
|
145 | + if (! empty($line->date_start) || ! empty($line->date_end)) |
|
146 | + { |
|
147 | + $format='day'; |
|
148 | + // Show duration if exists |
|
149 | + if ($line->date_start && $line->date_end) |
|
150 | + { |
|
151 | + $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($line->date_start, $format, false, $outputlangs),dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
152 | + } |
|
153 | + if ($line->date_start && ! $line->date_end) |
|
154 | + { |
|
155 | + $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($line->date_start, $format, false, $outputlangs)).')'; |
|
156 | + } |
|
157 | + if (! $line->date_start && $line->date_end) |
|
158 | + { |
|
159 | + $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
160 | + } |
|
161 | + //print '>'.$outputlangs->charset_output.','.$period; |
|
162 | + $libelleproduitservice=dol_concatdesc($libelleproduitservice, $period); |
|
163 | + //print $libelleproduitservice; |
|
164 | + } |
|
165 | 165 | |
166 | - return $libelleproduitservice; |
|
166 | + return $libelleproduitservice; |
|
167 | 167 | } |
168 | 168 |