@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | |
123 | 123 | // Margin Rate |
124 | 124 | if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
125 | - print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="3">'; |
|
126 | - print '<span id="marginRate"></span>'; // set by jquery (see below) |
|
127 | - print '</td></tr>'; |
|
125 | + print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="3">'; |
|
126 | + print '<span id="marginRate"></span>'; // set by jquery (see below) |
|
127 | + print '</td></tr>'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Mark Rate |
131 | 131 | if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
132 | - print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="3">'; |
|
133 | - print '<span id="markRate"></span>'; // set by jquery (see below) |
|
134 | - print '</td></tr>'; |
|
132 | + print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="3">'; |
|
133 | + print '<span id="markRate"></span>'; // set by jquery (see below) |
|
134 | + print '</td></tr>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | print "</table>"; |
@@ -168,99 +168,99 @@ discard block |
||
168 | 168 | $result = $db->query($sql); |
169 | 169 | if ($result) |
170 | 170 | { |
171 | - $num = $db->num_rows($result); |
|
172 | - |
|
173 | - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=".$object->id,$sortfield,$sortorder,'',0,0,''); |
|
174 | - |
|
175 | - $i = 0; |
|
176 | - print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
177 | - print "<table class=\"noborder\" width=\"100%\">"; |
|
178 | - |
|
179 | - print '<tr class="liste_titre">'; |
|
180 | - print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],"f.ref","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder); |
|
181 | - print_liste_field_titre("DateInvoice",$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder); |
|
182 | - print_liste_field_titre("SoldAmount",$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
183 | - print_liste_field_titre("PurchasedAmount",$_SERVER["PHP_SELF"],"buying_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
184 | - print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
185 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
186 | - print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
187 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
188 | - print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
189 | - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
190 | - print "</tr>\n"; |
|
191 | - |
|
192 | - $cumul_achat = 0; |
|
193 | - $cumul_vente = 0; |
|
194 | - |
|
195 | - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
196 | - |
|
197 | - if ($num > 0) |
|
198 | - { |
|
199 | - while ($i < $num /*&& $i < $conf->liste_limit*/) |
|
200 | - { |
|
201 | - $objp = $db->fetch_object($result); |
|
202 | - |
|
203 | - $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; |
|
204 | - $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; |
|
205 | - |
|
206 | - $sign = ''; |
|
207 | - if ($objp->type == Facture::TYPE_CREDIT_NOTE){ |
|
208 | - $sign = '-'; |
|
209 | - } |
|
210 | - |
|
211 | - print '<tr class="oddeven">'; |
|
212 | - print '<td>'; |
|
213 | - $invoicestatic->id=$objp->facid; |
|
214 | - $invoicestatic->ref=$objp->ref; |
|
215 | - print $invoicestatic->getNomUrl(1); |
|
216 | - print "</td>\n"; |
|
217 | - print "<td align=\"center\">"; |
|
218 | - print dol_print_date($db->jdate($objp->datef),'day')."</td>"; |
|
219 | - print "<td align=\"right\">".price($objp->selling_price, null, null, null, null, $rounding)."</td>\n"; |
|
220 | - print "<td align=\"right\">".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."</td>\n"; |
|
221 | - print "<td align=\"right\">".$sign.price($objp->marge, null, null, null, null, $rounding)."</td>\n"; |
|
222 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
223 | - print "<td align=\"right\">".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
224 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
225 | - print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
226 | - print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>'; |
|
227 | - print "</tr>\n"; |
|
228 | - $i++; |
|
229 | - $cumul_vente += $objp->selling_price; |
|
230 | - $cumul_achat += ($objp->type == 2 ? -1 : 1) * $objp->buying_price; |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - // affichage totaux marges |
|
235 | - |
|
236 | - $totalMargin = $cumul_vente - $cumul_achat; |
|
237 | - if ($totalMargin < 0) |
|
238 | - { |
|
239 | - $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; |
|
240 | - $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; |
|
241 | - } |
|
242 | - else |
|
243 | - { |
|
244 | - $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; |
|
245 | - $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; |
|
246 | - } |
|
247 | - |
|
248 | - // Total |
|
249 | - print '<tr class="liste_total">'; |
|
250 | - print '<td colspan=2>'.$langs->trans('TotalMargin')."</td>"; |
|
251 | - print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n"; |
|
252 | - print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n"; |
|
253 | - print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n"; |
|
254 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
255 | - print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
256 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
257 | - print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
258 | - print '<td align="right"> </td>'; |
|
259 | - print "</tr>\n"; |
|
171 | + $num = $db->num_rows($result); |
|
172 | + |
|
173 | + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=".$object->id,$sortfield,$sortorder,'',0,0,''); |
|
174 | + |
|
175 | + $i = 0; |
|
176 | + print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
177 | + print "<table class=\"noborder\" width=\"100%\">"; |
|
178 | + |
|
179 | + print '<tr class="liste_titre">'; |
|
180 | + print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],"f.ref","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder); |
|
181 | + print_liste_field_titre("DateInvoice",$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder); |
|
182 | + print_liste_field_titre("SoldAmount",$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
183 | + print_liste_field_titre("PurchasedAmount",$_SERVER["PHP_SELF"],"buying_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
184 | + print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
185 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
186 | + print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
187 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
188 | + print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
189 | + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); |
|
190 | + print "</tr>\n"; |
|
191 | + |
|
192 | + $cumul_achat = 0; |
|
193 | + $cumul_vente = 0; |
|
194 | + |
|
195 | + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
196 | + |
|
197 | + if ($num > 0) |
|
198 | + { |
|
199 | + while ($i < $num /*&& $i < $conf->liste_limit*/) |
|
200 | + { |
|
201 | + $objp = $db->fetch_object($result); |
|
202 | + |
|
203 | + $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; |
|
204 | + $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; |
|
205 | + |
|
206 | + $sign = ''; |
|
207 | + if ($objp->type == Facture::TYPE_CREDIT_NOTE){ |
|
208 | + $sign = '-'; |
|
209 | + } |
|
210 | + |
|
211 | + print '<tr class="oddeven">'; |
|
212 | + print '<td>'; |
|
213 | + $invoicestatic->id=$objp->facid; |
|
214 | + $invoicestatic->ref=$objp->ref; |
|
215 | + print $invoicestatic->getNomUrl(1); |
|
216 | + print "</td>\n"; |
|
217 | + print "<td align=\"center\">"; |
|
218 | + print dol_print_date($db->jdate($objp->datef),'day')."</td>"; |
|
219 | + print "<td align=\"right\">".price($objp->selling_price, null, null, null, null, $rounding)."</td>\n"; |
|
220 | + print "<td align=\"right\">".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."</td>\n"; |
|
221 | + print "<td align=\"right\">".$sign.price($objp->marge, null, null, null, null, $rounding)."</td>\n"; |
|
222 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
223 | + print "<td align=\"right\">".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
224 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
225 | + print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
226 | + print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>'; |
|
227 | + print "</tr>\n"; |
|
228 | + $i++; |
|
229 | + $cumul_vente += $objp->selling_price; |
|
230 | + $cumul_achat += ($objp->type == 2 ? -1 : 1) * $objp->buying_price; |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + // affichage totaux marges |
|
235 | + |
|
236 | + $totalMargin = $cumul_vente - $cumul_achat; |
|
237 | + if ($totalMargin < 0) |
|
238 | + { |
|
239 | + $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; |
|
240 | + $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; |
|
245 | + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; |
|
246 | + } |
|
247 | + |
|
248 | + // Total |
|
249 | + print '<tr class="liste_total">'; |
|
250 | + print '<td colspan=2>'.$langs->trans('TotalMargin')."</td>"; |
|
251 | + print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n"; |
|
252 | + print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n"; |
|
253 | + print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n"; |
|
254 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
255 | + print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
256 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
257 | + print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
258 | + print '<td align="right"> </td>'; |
|
259 | + print "</tr>\n"; |
|
260 | 260 | } |
261 | 261 | else |
262 | 262 | { |
263 | - dol_print_error($db); |
|
263 | + dol_print_error($db); |
|
264 | 264 | } |
265 | 265 | print "</table>"; |
266 | 266 | print '</div>'; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - dol_print_error('', 'Parameter socid not defined'); |
|
273 | + dol_print_error('', 'Parameter socid not defined'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) |
73 | 73 | { |
74 | - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
74 | + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
75 | 75 | } |
76 | 76 | else |
77 | 77 | { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) |
85 | 85 | { |
86 | - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
86 | + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
87 | 87 | } |
88 | 88 | else |
89 | 89 | { |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) |
97 | 97 | { |
98 | - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
98 | + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); |
|
99 | 99 | } |
100 | 100 | else |
101 | 101 | { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | print '<td>'; |
138 | 138 | print ' <input type="radio" name="MARGIN_TYPE" value="1" '; |
139 | 139 | if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') |
140 | - print 'checked '; |
|
140 | + print 'checked '; |
|
141 | 141 | print '/> '; |
142 | 142 | print $langs->trans('MargeType1'); |
143 | 143 | print '<br>'; |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | print '<td colspan="2" align="center">'; |
166 | 166 | if (! empty($conf->use_javascript_ajax)) |
167 | 167 | { |
168 | - print ajax_constantonoff('DISPLAY_MARGIN_RATES'); |
|
168 | + print ajax_constantonoff('DISPLAY_MARGIN_RATES'); |
|
169 | 169 | } |
170 | 170 | else |
171 | 171 | { |
172 | - if (empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
173 | - { |
|
174 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
179 | - } |
|
172 | + if (empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
173 | + { |
|
174 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
175 | + } |
|
176 | + else |
|
177 | + { |
|
178 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | print '</td>'; |
182 | 182 | print '<td>'.$langs->trans('MarginRate').' = '.$langs->trans('Margin').' / '.$langs->trans('BuyingPrice').'</td>'; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | print '<td colspan="2" align="center">'; |
189 | 189 | if (! empty($conf->use_javascript_ajax)) |
190 | 190 | { |
191 | - print ajax_constantonoff('DISPLAY_MARK_RATES'); |
|
191 | + print ajax_constantonoff('DISPLAY_MARK_RATES'); |
|
192 | 192 | } |
193 | 193 | else |
194 | 194 | { |
195 | - if (empty($conf->global->DISPLAY_MARK_RATES)) |
|
196 | - { |
|
197 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
198 | - } |
|
199 | - else |
|
200 | - { |
|
201 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
202 | - } |
|
195 | + if (empty($conf->global->DISPLAY_MARK_RATES)) |
|
196 | + { |
|
197 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
198 | + } |
|
199 | + else |
|
200 | + { |
|
201 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
202 | + } |
|
203 | 203 | } |
204 | 204 | print '</td>'; |
205 | 205 | print '<td>'.$langs->trans('MarkRate').' = '.$langs->trans('Margin').' / '.$langs->trans('SellingPrice').'</td>'; |
@@ -211,18 +211,18 @@ discard block |
||
211 | 211 | print '<td colspan="2" align="center">'; |
212 | 212 | if (! empty($conf->use_javascript_ajax)) |
213 | 213 | { |
214 | - print ajax_constantonoff('ForceBuyingPriceIfNull'); |
|
214 | + print ajax_constantonoff('ForceBuyingPriceIfNull'); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - if (empty($conf->global->ForceBuyingPriceIfNull)) |
|
219 | - { |
|
220 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
221 | - } |
|
222 | - else |
|
223 | - { |
|
224 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
225 | - } |
|
218 | + if (empty($conf->global->ForceBuyingPriceIfNull)) |
|
219 | + { |
|
220 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
221 | + } |
|
222 | + else |
|
223 | + { |
|
224 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | print '</td>'; |
228 | 228 | print '<td>'.$langs->trans('ForceBuyingPriceIfNullDetails').'</td>'; |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | |
231 | 231 | // GLOBAL DISCOUNT MANAGEMENT |
232 | 232 | $methods = array( |
233 | - 1 => $langs->trans('UseDiscountAsProduct'), |
|
234 | - 2 => $langs->trans('UseDiscountAsService'), |
|
235 | - 3 => $langs->trans('UseDiscountOnTotal') |
|
233 | + 1 => $langs->trans('UseDiscountAsProduct'), |
|
234 | + 2 => $langs->trans('UseDiscountAsService'), |
|
235 | + 3 => $langs->trans('UseDiscountOnTotal') |
|
236 | 236 | ); |
237 | 237 | |
238 | 238 |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | $startdate=$enddate=''; |
59 | 59 | |
60 | 60 | if (!empty($_POST['startdatemonth'])) |
61 | - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); |
|
61 | + $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); |
|
62 | 62 | if (!empty($_POST['enddatemonth'])) |
63 | - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); |
|
63 | + $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /* |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | $client = false; |
93 | 93 | if ($socid > 0) { |
94 | 94 | |
95 | - $soc = new Societe($db); |
|
96 | - $soc->fetch($socid); |
|
97 | - |
|
98 | - if ($soc->client) |
|
99 | - { |
|
100 | - print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; |
|
101 | - print '<td class="maxwidthonsmartphone" colspan="4">'; |
|
102 | - print $form->select_company($socid, 'socid', 'client=1 OR client=3', 1, 0, 0); |
|
103 | - //$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1 OR client=3',1,0,1); |
|
104 | - print '</td></tr>'; |
|
105 | - |
|
106 | - $client = true; |
|
107 | - if (! $sortorder) $sortorder="DESC"; |
|
108 | - if (! $sortfield) $sortfield="f.datef"; |
|
109 | - } |
|
95 | + $soc = new Societe($db); |
|
96 | + $soc->fetch($socid); |
|
97 | + |
|
98 | + if ($soc->client) |
|
99 | + { |
|
100 | + print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; |
|
101 | + print '<td class="maxwidthonsmartphone" colspan="4">'; |
|
102 | + print $form->select_company($socid, 'socid', 'client=1 OR client=3', 1, 0, 0); |
|
103 | + //$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1 OR client=3',1,0,1); |
|
104 | + print '</td></tr>'; |
|
105 | + |
|
106 | + $client = true; |
|
107 | + if (! $sortorder) $sortorder="DESC"; |
|
108 | + if (! $sortfield) $sortfield="f.datef"; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | else { |
112 | - print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; |
|
113 | - print '<td class="maxwidthonsmartphone" colspan="4">'; |
|
114 | - print $form->select_company(null, 'socid', 'client=1 OR client=3', 1, 0, 0); |
|
115 | - //$form->form_thirdparty($_SERVER['PHP_SELF'],null,'socid','client=1 OR client=3',1,0,1); |
|
116 | - print '</td></tr>'; |
|
112 | + print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; |
|
113 | + print '<td class="maxwidthonsmartphone" colspan="4">'; |
|
114 | + print $form->select_company(null, 'socid', 'client=1 OR client=3', 1, 0, 0); |
|
115 | + //$form->form_thirdparty($_SERVER['PHP_SELF'],null,'socid','client=1 OR client=3',1,0,1); |
|
116 | + print '</td></tr>'; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | $sortfield = GETPOST("sortfield",'alpha'); |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | if (! $sortorder) $sortorder="ASC"; |
122 | 122 | if (! $sortfield) |
123 | 123 | { |
124 | - if ($client) |
|
125 | - { |
|
126 | - $sortfield="f.datef"; |
|
127 | - $sortorder="DESC"; |
|
128 | - } |
|
129 | - else |
|
130 | - { |
|
131 | - $sortfield="s.nom"; |
|
132 | - $sortorder="ASC"; |
|
133 | - } |
|
124 | + if ($client) |
|
125 | + { |
|
126 | + $sortfield="f.datef"; |
|
127 | + $sortorder="DESC"; |
|
128 | + } |
|
129 | + else |
|
130 | + { |
|
131 | + $sortfield="s.nom"; |
|
132 | + $sortorder="ASC"; |
|
133 | + } |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Products |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | $TProducts = array(); |
140 | 140 | foreach($TRes as $prod) { |
141 | - $TProducts[$prod['key']] = $prod['label']; |
|
141 | + $TProducts[$prod['key']] = $prod['label']; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>'; |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | |
183 | 183 | // Margin Rate |
184 | 184 | if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
185 | - print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">'; |
|
186 | - print '<span id="marginRate"></span>'; // set by jquery (see below) |
|
187 | - print '</td></tr>'; |
|
185 | + print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">'; |
|
186 | + print '<span id="marginRate"></span>'; // set by jquery (see below) |
|
187 | + print '</td></tr>'; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | // Mark Rate |
191 | 191 | if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
192 | - print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">'; |
|
193 | - print '<span id="markRate"></span>'; // set by jquery (see below) |
|
194 | - print '</td></tr>'; |
|
192 | + print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">'; |
|
193 | + print '<span id="markRate"></span>'; // set by jquery (see below) |
|
194 | + print '</td></tr>'; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | print "</table>"; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
212 | 212 | $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; |
213 | 213 | if(! empty($TSelectedCats)) { |
214 | - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product'; |
|
214 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product'; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | $sql.= " AND d.fk_facture = f.rowid"; |
224 | 224 | $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; |
225 | 225 | if(! empty($TSelectedProducts)) { |
226 | - $sql .= ' AND d.fk_product IN ('.implode(',', $TSelectedProducts) . ')'; |
|
226 | + $sql .= ' AND d.fk_product IN ('.implode(',', $TSelectedProducts) . ')'; |
|
227 | 227 | } |
228 | 228 | if(! empty($TSelectedCats)) { |
229 | - $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats) . ')'; |
|
229 | + $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats) . ')'; |
|
230 | 230 | } |
231 | 231 | if (!empty($startdate)) |
232 | 232 | $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; |
@@ -245,127 +245,127 @@ discard block |
||
245 | 245 | $result = $db->query($sql); |
246 | 246 | if ($result) |
247 | 247 | { |
248 | - $num = $db->num_rows($result); |
|
249 | - |
|
250 | - print '<br>'; |
|
251 | - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); |
|
252 | - |
|
253 | - if ($conf->global->MARGIN_TYPE == "1") |
|
254 | - $labelcostprice='BuyingPrice'; |
|
255 | - else // value is 'costprice' or 'pmp' |
|
256 | - $labelcostprice='CostPrice'; |
|
257 | - |
|
258 | - $i = 0; |
|
259 | - print "<table class=\"noborder\" width=\"100%\">"; |
|
260 | - |
|
261 | - print '<tr class="liste_titre">'; |
|
262 | - if (! empty($client)) { |
|
263 | - print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],"f.ref","","&socid=".$socid,'',$sortfield,$sortorder); |
|
264 | - print_liste_field_titre("DateInvoice",$_SERVER["PHP_SELF"],"f.datef","","&socid=".$socid,'align="center"',$sortfield,$sortorder); |
|
265 | - } |
|
266 | - else |
|
267 | - print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'',$sortfield,$sortorder); |
|
268 | - print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
269 | - print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"],"buying_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
270 | - print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
271 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
272 | - print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
273 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
274 | - print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
275 | - print "</tr>\n"; |
|
276 | - |
|
277 | - $cumul_achat = 0; |
|
278 | - $cumul_vente = 0; |
|
279 | - |
|
280 | - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
281 | - |
|
282 | - if ($num > 0) |
|
283 | - { |
|
284 | - while ($i < $num /*&& $i < $conf->liste_limit*/) |
|
285 | - { |
|
286 | - $objp = $db->fetch_object($result); |
|
287 | - |
|
288 | - $pa = $objp->buying_price; |
|
289 | - $pv = $objp->selling_price; |
|
290 | - $marge = $objp->marge; |
|
291 | - |
|
292 | - if ($marge < 0) |
|
293 | - { |
|
294 | - $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; |
|
295 | - $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; |
|
296 | - } |
|
297 | - else |
|
298 | - { |
|
299 | - $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; |
|
300 | - $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; |
|
301 | - } |
|
302 | - |
|
303 | - print '<tr class="oddeven">'; |
|
304 | - if ($client) { |
|
305 | - print '<td>'; |
|
306 | - $invoicestatic->id=$objp->facid; |
|
307 | - $invoicestatic->ref=$objp->ref; |
|
308 | - print $invoicestatic->getNomUrl(1); |
|
309 | - print "</td>\n"; |
|
310 | - print "<td align=\"center\">"; |
|
311 | - print dol_print_date($db->jdate($objp->datef),'day')."</td>"; |
|
312 | - } |
|
313 | - else { |
|
314 | - $companystatic->id=$objp->socid; |
|
315 | - $companystatic->name=$objp->name; |
|
316 | - $companystatic->client=$objp->client; |
|
317 | - print "<td>".$companystatic->getNomUrl(1,'margin')."</td>\n"; |
|
318 | - } |
|
319 | - |
|
320 | - print "<td align=\"right\">".price($pv, null, null, null, null, $rounding)."</td>\n"; |
|
321 | - print "<td align=\"right\">".price($pa, null, null, null, null, $rounding)."</td>\n"; |
|
322 | - print "<td align=\"right\">".price($marge, null, null, null, null, $rounding)."</td>\n"; |
|
323 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
324 | - print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
325 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
326 | - print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
327 | - print "</tr>\n"; |
|
328 | - |
|
329 | - $i++; |
|
330 | - $cumul_achat += $objp->buying_price; |
|
331 | - $cumul_vente += $objp->selling_price; |
|
332 | - } |
|
333 | - } |
|
334 | - |
|
335 | - // affichage totaux marges |
|
336 | - |
|
337 | - $totalMargin = $cumul_vente - $cumul_achat; |
|
338 | - /*if ($totalMargin < 0) |
|
248 | + $num = $db->num_rows($result); |
|
249 | + |
|
250 | + print '<br>'; |
|
251 | + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); |
|
252 | + |
|
253 | + if ($conf->global->MARGIN_TYPE == "1") |
|
254 | + $labelcostprice='BuyingPrice'; |
|
255 | + else // value is 'costprice' or 'pmp' |
|
256 | + $labelcostprice='CostPrice'; |
|
257 | + |
|
258 | + $i = 0; |
|
259 | + print "<table class=\"noborder\" width=\"100%\">"; |
|
260 | + |
|
261 | + print '<tr class="liste_titre">'; |
|
262 | + if (! empty($client)) { |
|
263 | + print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],"f.ref","","&socid=".$socid,'',$sortfield,$sortorder); |
|
264 | + print_liste_field_titre("DateInvoice",$_SERVER["PHP_SELF"],"f.datef","","&socid=".$socid,'align="center"',$sortfield,$sortorder); |
|
265 | + } |
|
266 | + else |
|
267 | + print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'',$sortfield,$sortorder); |
|
268 | + print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
269 | + print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"],"buying_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
270 | + print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
271 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
272 | + print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
273 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
274 | + print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder); |
|
275 | + print "</tr>\n"; |
|
276 | + |
|
277 | + $cumul_achat = 0; |
|
278 | + $cumul_vente = 0; |
|
279 | + |
|
280 | + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
281 | + |
|
282 | + if ($num > 0) |
|
283 | + { |
|
284 | + while ($i < $num /*&& $i < $conf->liste_limit*/) |
|
285 | + { |
|
286 | + $objp = $db->fetch_object($result); |
|
287 | + |
|
288 | + $pa = $objp->buying_price; |
|
289 | + $pv = $objp->selling_price; |
|
290 | + $marge = $objp->marge; |
|
291 | + |
|
292 | + if ($marge < 0) |
|
293 | + { |
|
294 | + $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; |
|
295 | + $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; |
|
300 | + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; |
|
301 | + } |
|
302 | + |
|
303 | + print '<tr class="oddeven">'; |
|
304 | + if ($client) { |
|
305 | + print '<td>'; |
|
306 | + $invoicestatic->id=$objp->facid; |
|
307 | + $invoicestatic->ref=$objp->ref; |
|
308 | + print $invoicestatic->getNomUrl(1); |
|
309 | + print "</td>\n"; |
|
310 | + print "<td align=\"center\">"; |
|
311 | + print dol_print_date($db->jdate($objp->datef),'day')."</td>"; |
|
312 | + } |
|
313 | + else { |
|
314 | + $companystatic->id=$objp->socid; |
|
315 | + $companystatic->name=$objp->name; |
|
316 | + $companystatic->client=$objp->client; |
|
317 | + print "<td>".$companystatic->getNomUrl(1,'margin')."</td>\n"; |
|
318 | + } |
|
319 | + |
|
320 | + print "<td align=\"right\">".price($pv, null, null, null, null, $rounding)."</td>\n"; |
|
321 | + print "<td align=\"right\">".price($pa, null, null, null, null, $rounding)."</td>\n"; |
|
322 | + print "<td align=\"right\">".price($marge, null, null, null, null, $rounding)."</td>\n"; |
|
323 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
324 | + print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
325 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
326 | + print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
327 | + print "</tr>\n"; |
|
328 | + |
|
329 | + $i++; |
|
330 | + $cumul_achat += $objp->buying_price; |
|
331 | + $cumul_vente += $objp->selling_price; |
|
332 | + } |
|
333 | + } |
|
334 | + |
|
335 | + // affichage totaux marges |
|
336 | + |
|
337 | + $totalMargin = $cumul_vente - $cumul_achat; |
|
338 | + /*if ($totalMargin < 0) |
|
339 | 339 | { |
340 | 340 | $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; |
341 | 341 | $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; |
342 | 342 | } |
343 | 343 | else |
344 | 344 | {*/ |
345 | - $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; |
|
346 | - $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; |
|
347 | - //} |
|
348 | - |
|
349 | - print '<tr class="liste_total">'; |
|
350 | - if ($client) |
|
351 | - print '<td colspan=2>'; |
|
352 | - else |
|
353 | - print '<td>'; |
|
354 | - print $langs->trans('TotalMargin')."</td>"; |
|
355 | - print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n"; |
|
356 | - print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n"; |
|
357 | - print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n"; |
|
358 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
359 | - print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
360 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
361 | - print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
362 | - print "</tr>\n"; |
|
363 | - |
|
364 | - print "</table>"; |
|
345 | + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; |
|
346 | + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; |
|
347 | + //} |
|
348 | + |
|
349 | + print '<tr class="liste_total">'; |
|
350 | + if ($client) |
|
351 | + print '<td colspan=2>'; |
|
352 | + else |
|
353 | + print '<td>'; |
|
354 | + print $langs->trans('TotalMargin')."</td>"; |
|
355 | + print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n"; |
|
356 | + print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n"; |
|
357 | + print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n"; |
|
358 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
359 | + print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
360 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
361 | + print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; |
|
362 | + print "</tr>\n"; |
|
363 | + |
|
364 | + print "</table>"; |
|
365 | 365 | } |
366 | 366 | else |
367 | 367 | { |
368 | - dol_print_error($db); |
|
368 | + dol_print_error($db); |
|
369 | 369 | } |
370 | 370 | $db->free($result); |
371 | 371 |
@@ -201,115 +201,115 @@ |
||
201 | 201 | $nbtotalofrecords = ''; |
202 | 202 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { |
203 | 203 | |
204 | - dol_syslog(__FILE__, LOG_DEBUG); |
|
205 | - $result = $db->query($sql); |
|
206 | - $nbtotalofrecords = $db->num_rows($result); |
|
207 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
208 | - { |
|
209 | - $page = 0; |
|
210 | - $offset = 0; |
|
211 | - } |
|
204 | + dol_syslog(__FILE__, LOG_DEBUG); |
|
205 | + $result = $db->query($sql); |
|
206 | + $nbtotalofrecords = $db->num_rows($result); |
|
207 | + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
208 | + { |
|
209 | + $page = 0; |
|
210 | + $offset = 0; |
|
211 | + } |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | $sql .= $db->plimit($limit+1, $offset); |
215 | 215 | |
216 | 216 | $result = $db->query($sql); |
217 | 217 | if ($result) { |
218 | - $num = $db->num_rows($result); |
|
218 | + $num = $db->num_rows($result); |
|
219 | 219 | |
220 | - print '<br>'; |
|
221 | - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); |
|
220 | + print '<br>'; |
|
221 | + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); |
|
222 | 222 | |
223 | - if ($conf->global->MARGIN_TYPE == "1") |
|
224 | - $labelcostprice='BuyingPrice'; |
|
225 | - else // value is 'costprice' or 'pmp' |
|
226 | - $labelcostprice='CostPrice'; |
|
223 | + if ($conf->global->MARGIN_TYPE == "1") |
|
224 | + $labelcostprice='BuyingPrice'; |
|
225 | + else // value is 'costprice' or 'pmp' |
|
226 | + $labelcostprice='CostPrice'; |
|
227 | 227 | |
228 | - $moreforfilter=''; |
|
228 | + $moreforfilter=''; |
|
229 | 229 | |
230 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
231 | - //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
232 | - //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
233 | - $selectedfields=''; |
|
230 | + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
231 | + //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
232 | + //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
233 | + $selectedfields=''; |
|
234 | 234 | |
235 | 235 | print '<div class="div-table-responsive">'; |
236 | 236 | print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
237 | 237 | |
238 | - print '<tr class="liste_titre liste_titre_search">'; |
|
239 | - print '<td><input type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; |
|
240 | - print '<td></td>'; |
|
241 | - print '<td></td>'; |
|
242 | - print '<td></td>'; |
|
243 | - print '<td></td>'; |
|
244 | - print '<td></td>'; |
|
238 | + print '<tr class="liste_titre liste_titre_search">'; |
|
239 | + print '<td><input type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; |
|
240 | + print '<td></td>'; |
|
241 | + print '<td></td>'; |
|
242 | + print '<td></td>'; |
|
243 | + print '<td></td>'; |
|
244 | + print '<td></td>'; |
|
245 | 245 | print '<td class="liste_titre" align="middle">'; |
246 | 246 | $searchpitco=$form->showFilterButtons(); |
247 | 247 | print $searchpitco; |
248 | 248 | print '</td>'; |
249 | - print "</tr>\n"; |
|
250 | - |
|
251 | - print '<tr class="liste_titre">'; |
|
252 | - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); |
|
253 | - print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); |
|
254 | - print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); |
|
255 | - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); |
|
256 | - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); |
|
257 | - print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); |
|
258 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); |
|
259 | - print "</tr>\n"; |
|
249 | + print "</tr>\n"; |
|
250 | + |
|
251 | + print '<tr class="liste_titre">'; |
|
252 | + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); |
|
253 | + print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); |
|
254 | + print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); |
|
255 | + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); |
|
256 | + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); |
|
257 | + print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); |
|
258 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); |
|
259 | + print "</tr>\n"; |
|
260 | 260 | |
261 | 261 | $i=0; |
262 | - while ($i < min($num, $limit)) |
|
263 | - { |
|
264 | - $objp = $db->fetch_object($result); |
|
265 | - |
|
266 | - print '<tr class="oddeven">'; |
|
267 | - print '<td>'; |
|
268 | - $result_inner = $invoicestatic->fetch($objp->invoiceid); |
|
269 | - if ($result_inner < 0) { |
|
270 | - setEventMessages($invoicestatic->error, null, 'errors'); |
|
271 | - } else { |
|
272 | - print $invoicestatic->getNomUrl(1); |
|
273 | - } |
|
274 | - print '</td>'; |
|
275 | - print '<td>'; |
|
276 | - if (! empty($objp->fk_product)) { |
|
277 | - $result_inner = $productstatic->fetch($objp->fk_product); |
|
278 | - if ($result_inner < 0) { |
|
279 | - setEventMessages($productstatic->error, null, 'errors'); |
|
280 | - } else { |
|
281 | - print $productstatic->getNomUrl(1); |
|
282 | - } |
|
283 | - } else { |
|
284 | - print $objp->label; |
|
285 | - print ' '; |
|
286 | - print $objp->description; |
|
287 | - } |
|
288 | - print '</td>'; |
|
289 | - print '<td align="right">'; |
|
290 | - print price($objp->subprice); |
|
291 | - print '</td>'; |
|
292 | - print '<td align="right">'; |
|
293 | - print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="right flat">'; |
|
294 | - print '</td>'; |
|
295 | - print '<td align="right">'; |
|
296 | - print $objp->qty; |
|
297 | - print '</td>'; |
|
298 | - print '<td align="right">'; |
|
299 | - print price($objp->total_ht); |
|
300 | - print '</td>'; |
|
301 | - print '<td></td>'; |
|
302 | - |
|
303 | - print "</tr>\n"; |
|
304 | - |
|
305 | - $i ++; |
|
306 | - } |
|
307 | - |
|
308 | - print "</table>"; |
|
309 | - |
|
310 | - print "</div>"; |
|
262 | + while ($i < min($num, $limit)) |
|
263 | + { |
|
264 | + $objp = $db->fetch_object($result); |
|
265 | + |
|
266 | + print '<tr class="oddeven">'; |
|
267 | + print '<td>'; |
|
268 | + $result_inner = $invoicestatic->fetch($objp->invoiceid); |
|
269 | + if ($result_inner < 0) { |
|
270 | + setEventMessages($invoicestatic->error, null, 'errors'); |
|
271 | + } else { |
|
272 | + print $invoicestatic->getNomUrl(1); |
|
273 | + } |
|
274 | + print '</td>'; |
|
275 | + print '<td>'; |
|
276 | + if (! empty($objp->fk_product)) { |
|
277 | + $result_inner = $productstatic->fetch($objp->fk_product); |
|
278 | + if ($result_inner < 0) { |
|
279 | + setEventMessages($productstatic->error, null, 'errors'); |
|
280 | + } else { |
|
281 | + print $productstatic->getNomUrl(1); |
|
282 | + } |
|
283 | + } else { |
|
284 | + print $objp->label; |
|
285 | + print ' '; |
|
286 | + print $objp->description; |
|
287 | + } |
|
288 | + print '</td>'; |
|
289 | + print '<td align="right">'; |
|
290 | + print price($objp->subprice); |
|
291 | + print '</td>'; |
|
292 | + print '<td align="right">'; |
|
293 | + print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="right flat">'; |
|
294 | + print '</td>'; |
|
295 | + print '<td align="right">'; |
|
296 | + print $objp->qty; |
|
297 | + print '</td>'; |
|
298 | + print '<td align="right">'; |
|
299 | + print price($objp->total_ht); |
|
300 | + print '</td>'; |
|
301 | + print '<td></td>'; |
|
302 | + |
|
303 | + print "</tr>\n"; |
|
304 | + |
|
305 | + $i ++; |
|
306 | + } |
|
307 | + |
|
308 | + print "</table>"; |
|
309 | + |
|
310 | + print "</div>"; |
|
311 | 311 | } else { |
312 | - dol_print_error($db); |
|
312 | + dol_print_error($db); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 |
@@ -29,29 +29,29 @@ |
||
29 | 29 | |
30 | 30 | if ($action == 'update' && is_array($arrayofparameters)) |
31 | 31 | { |
32 | - $db->begin(); |
|
32 | + $db->begin(); |
|
33 | 33 | |
34 | - $ok=true; |
|
35 | - foreach($arrayofparameters as $key => $val) |
|
36 | - { |
|
37 | - $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity); |
|
38 | - if ($result < 0) |
|
39 | - { |
|
40 | - $ok=false; |
|
41 | - break; |
|
42 | - } |
|
43 | - } |
|
34 | + $ok=true; |
|
35 | + foreach($arrayofparameters as $key => $val) |
|
36 | + { |
|
37 | + $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity); |
|
38 | + if ($result < 0) |
|
39 | + { |
|
40 | + $ok=false; |
|
41 | + break; |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - if (! $error) |
|
46 | - { |
|
47 | - $db->commit(); |
|
48 | - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
49 | - } |
|
50 | - else |
|
51 | - { |
|
52 | - $db->rollback(); |
|
53 | - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); |
|
54 | - } |
|
45 | + if (! $error) |
|
46 | + { |
|
47 | + $db->commit(); |
|
48 | + if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
49 | + } |
|
50 | + else |
|
51 | + { |
|
52 | + $db->rollback(); |
|
53 | + if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class InfoBox |
29 | 29 | { |
30 | - /** |
|
31 | - * Name of positions 0=Home, 1=... |
|
32 | - * |
|
33 | - * @return string[] Array with list of zones |
|
34 | - */ |
|
35 | - static function getListOfPagesForBoxes() |
|
36 | - { |
|
37 | - return array(0=>'Home'); |
|
38 | - } |
|
30 | + /** |
|
31 | + * Name of positions 0=Home, 1=... |
|
32 | + * |
|
33 | + * @return string[] Array with list of zones |
|
34 | + */ |
|
35 | + static function getListOfPagesForBoxes() |
|
36 | + { |
|
37 | + return array(0=>'Home'); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Return array of boxes qualified for area and user |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | $sql.= " ORDER BY b.box_order"; |
69 | 69 | } |
70 | 70 | else // available |
71 | - { |
|
71 | + { |
|
72 | 72 | $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; |
73 | 73 | $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; |
74 | - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; |
|
74 | + $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | { |
98 | 98 | $boxname=preg_replace('/\.php$/i','',$obj->file); |
99 | 99 | $relsourcefile = "/core/boxes/".$boxname.".php"; |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>'; |
|
102 | + //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>'; |
|
103 | 103 | |
104 | - // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then |
|
104 | + // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then |
|
105 | 105 | // the "enabled" condition for modules forbidden for external users and the depends condition can be done. |
106 | 106 | // Goal is to avoid making a "new" done for each boxes returned by select. |
107 | 107 | dol_include_once($relsourcefile); |
108 | 108 | if (class_exists($boxname)) |
109 | 109 | { |
110 | - $box=new $boxname($db,$obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. |
|
110 | + $box=new $boxname($db,$obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. |
|
111 | 111 | //$box=new stdClass(); |
112 | 112 | |
113 | 113 | // box properties |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); |
118 | 118 | $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); |
119 | 119 | $box->sourcefile= $relsourcefile; |
120 | - $box->class = $boxname; |
|
120 | + $box->class = $boxname; |
|
121 | 121 | |
122 | - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database |
|
122 | + if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database |
|
123 | 123 | { |
124 | 124 | if (is_numeric($box->box_order)) |
125 | 125 | { |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | { |
139 | 139 | foreach($box->depends as $moduleelem) |
140 | 140 | { |
141 | - $arrayelem=explode('|',$moduleelem); |
|
142 | - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) |
|
143 | - foreach($arrayelem as $module) |
|
144 | - { |
|
145 | - $tmpmodule=preg_replace('/@[^@]+/','',$module); |
|
146 | - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; |
|
147 | - //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>'; |
|
148 | - } |
|
149 | - if (empty($tmpenabled)) // We found at least one module required that is disabled |
|
150 | - { |
|
151 | - $enabled=0; |
|
152 | - break; |
|
153 | - } |
|
141 | + $arrayelem=explode('|',$moduleelem); |
|
142 | + $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) |
|
143 | + foreach($arrayelem as $module) |
|
144 | + { |
|
145 | + $tmpmodule=preg_replace('/@[^@]+/','',$module); |
|
146 | + if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; |
|
147 | + //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>'; |
|
148 | + } |
|
149 | + if (empty($tmpenabled)) // We found at least one module required that is disabled |
|
150 | + { |
|
151 | + $enabled=0; |
|
152 | + break; |
|
153 | + } |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | //print '=>'.$boxname.'-enabled='.$enabled.'<br>'; |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | else unset($box); |
161 | 161 | } |
162 | 162 | else |
163 | - { |
|
164 | - dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); |
|
165 | - } |
|
163 | + { |
|
164 | + dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); |
|
165 | + } |
|
166 | 166 | } |
167 | 167 | $j++; |
168 | 168 | } |
169 | 169 | } |
170 | 170 | else |
171 | - { |
|
172 | - dol_syslog($db->lasterror(),LOG_ERR); |
|
171 | + { |
|
172 | + dol_syslog($db->lasterror(),LOG_ERR); |
|
173 | 173 | return array('error'=>$db->lasterror()); |
174 | 174 | } |
175 | 175 |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | public $db; |
34 | 34 | |
35 | 35 | /** |
36 | - * @var string Error code (or message) |
|
37 | - */ |
|
38 | - public $error=''; |
|
36 | + * @var string Error code (or message) |
|
37 | + */ |
|
38 | + public $error=''; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -50,99 +50,99 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
53 | - /** |
|
54 | - * Show a combo list with contracts qualified for a third party |
|
55 | - * |
|
56 | - * @param int $socid Id third party (-1=all, 0=only interventions not linked to a third party, id=intervention not linked or linked to third party id) |
|
57 | - * @param int $selected Id intervention preselected |
|
58 | - * @param string $htmlname Nom de la zone html |
|
59 | - * @param int $maxlength Maximum length of label |
|
60 | - * @param int $showempty Show empty line |
|
61 | - * @return int Nbre of project if OK, <0 if KO |
|
62 | - */ |
|
63 | - function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
64 | - { |
|
53 | + /** |
|
54 | + * Show a combo list with contracts qualified for a third party |
|
55 | + * |
|
56 | + * @param int $socid Id third party (-1=all, 0=only interventions not linked to a third party, id=intervention not linked or linked to third party id) |
|
57 | + * @param int $selected Id intervention preselected |
|
58 | + * @param string $htmlname Nom de la zone html |
|
59 | + * @param int $maxlength Maximum length of label |
|
60 | + * @param int $showempty Show empty line |
|
61 | + * @return int Nbre of project if OK, <0 if KO |
|
62 | + */ |
|
63 | + function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
64 | + { |
|
65 | 65 | // phpcs:enable |
66 | - global $db,$user,$conf,$langs; |
|
66 | + global $db,$user,$conf,$langs; |
|
67 | 67 | |
68 | - $out=''; |
|
68 | + $out=''; |
|
69 | 69 | |
70 | - $hideunselectables=false; |
|
70 | + $hideunselectables=false; |
|
71 | 71 | |
72 | - // Search all contacts |
|
73 | - $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
|
74 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
75 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
76 | - if ($socid != '') |
|
77 | - { |
|
78 | - if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | - else $sql.= " AND f.fk_soc = ".$socid; |
|
80 | - } |
|
72 | + // Search all contacts |
|
73 | + $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
|
74 | + $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
75 | + $sql.= " WHERE f.entity = ".$conf->entity; |
|
76 | + if ($socid != '') |
|
77 | + { |
|
78 | + if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
79 | + else $sql.= " AND f.fk_soc = ".$socid; |
|
80 | + } |
|
81 | 81 | |
82 | - dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
|
83 | - $resql=$db->query($sql); |
|
84 | - if ($resql) |
|
85 | - { |
|
86 | - $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
88 | - $num = $db->num_rows($resql); |
|
89 | - $i = 0; |
|
90 | - if ($num) |
|
91 | - { |
|
92 | - while ($i < $num) |
|
93 | - { |
|
94 | - $obj = $db->fetch_object($resql); |
|
95 | - // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
|
96 | - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
97 | - { |
|
98 | - // Do nothing |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - $labeltoshow=dol_trunc($obj->ref,18); |
|
103 | - if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
|
104 | - { |
|
105 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
106 | - } |
|
107 | - else |
|
108 | - { |
|
109 | - $disabled=0; |
|
110 | - if (! $obj->fk_statut > 0) |
|
111 | - { |
|
112 | - $disabled=1; |
|
113 | - $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
114 | - } |
|
115 | - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
116 | - { |
|
117 | - $disabled=1; |
|
118 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
119 | - } |
|
82 | + dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
|
83 | + $resql=$db->query($sql); |
|
84 | + if ($resql) |
|
85 | + { |
|
86 | + $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
87 | + if ($showempty) $out.='<option value="0"> </option>'; |
|
88 | + $num = $db->num_rows($resql); |
|
89 | + $i = 0; |
|
90 | + if ($num) |
|
91 | + { |
|
92 | + while ($i < $num) |
|
93 | + { |
|
94 | + $obj = $db->fetch_object($resql); |
|
95 | + // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
|
96 | + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
97 | + { |
|
98 | + // Do nothing |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + $labeltoshow=dol_trunc($obj->ref,18); |
|
103 | + if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
|
104 | + { |
|
105 | + $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
106 | + } |
|
107 | + else |
|
108 | + { |
|
109 | + $disabled=0; |
|
110 | + if (! $obj->fk_statut > 0) |
|
111 | + { |
|
112 | + $disabled=1; |
|
113 | + $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
114 | + } |
|
115 | + if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
116 | + { |
|
117 | + $disabled=1; |
|
118 | + $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
119 | + } |
|
120 | 120 | |
121 | - if ($hideunselectables && $disabled) |
|
122 | - { |
|
123 | - $resultat=''; |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
128 | - if ($disabled) $resultat.=' disabled'; |
|
129 | - $resultat.='>'.$labeltoshow; |
|
130 | - $resultat.='</option>'; |
|
131 | - } |
|
132 | - $out.=$resultat; |
|
133 | - } |
|
134 | - } |
|
135 | - $i++; |
|
136 | - } |
|
137 | - } |
|
138 | - $out.='</select>'; |
|
139 | - $db->free($resql); |
|
140 | - return $out; |
|
141 | - } |
|
142 | - else |
|
143 | - { |
|
144 | - dol_print_error($db); |
|
145 | - return ''; |
|
146 | - } |
|
147 | - } |
|
121 | + if ($hideunselectables && $disabled) |
|
122 | + { |
|
123 | + $resultat=''; |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + $resultat='<option value="'.$obj->rowid.'"'; |
|
128 | + if ($disabled) $resultat.=' disabled'; |
|
129 | + $resultat.='>'.$labeltoshow; |
|
130 | + $resultat.='</option>'; |
|
131 | + } |
|
132 | + $out.=$resultat; |
|
133 | + } |
|
134 | + } |
|
135 | + $i++; |
|
136 | + } |
|
137 | + } |
|
138 | + $out.='</select>'; |
|
139 | + $db->free($resql); |
|
140 | + return $out; |
|
141 | + } |
|
142 | + else |
|
143 | + { |
|
144 | + dol_print_error($db); |
|
145 | + return ''; |
|
146 | + } |
|
147 | + } |
|
148 | 148 | } |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public $db; |
38 | 38 | |
39 | - var $dir; // Directory with all core and external triggers files |
|
39 | + var $dir; // Directory with all core and external triggers files |
|
40 | 40 | |
41 | 41 | /** |
42 | - * @var string[] Error codes (or messages) |
|
43 | - */ |
|
44 | - public $errors = array(); |
|
42 | + * @var string[] Error codes (or messages) |
|
43 | + */ |
|
44 | + public $errors = array(); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Constructor |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | // Check parameters |
72 | 72 | if (! is_object($object) || ! is_object($conf)) // Error |
73 | 73 | { |
74 | - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
74 | + $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
75 | 75 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
76 | - $this->errors[]=$this->error; |
|
76 | + $this->errors[]=$this->error; |
|
77 | 77 | return -1; |
78 | 78 | } |
79 | 79 | if (! is_object($langs)) // Warning |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | $files = array(); |
93 | 93 | $modules = array(); |
94 | 94 | $orders = array(); |
95 | - $i=0; |
|
95 | + $i=0; |
|
96 | 96 | |
97 | - $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
97 | + $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
98 | 98 | foreach($dirtriggers as $reldir) |
99 | 99 | { |
100 | 100 | $dir=dol_buildpath($reldir,0); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | { |
112 | 112 | if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) |
113 | 113 | { |
114 | - $part1=$reg[1]; |
|
115 | - $part2=$reg[2]; |
|
116 | - $part3=$reg[3]; |
|
114 | + $part1=$reg[1]; |
|
115 | + $part2=$reg[2]; |
|
116 | + $part3=$reg[3]; |
|
117 | 117 | |
118 | 118 | $nbfile++; |
119 | 119 | |
@@ -175,22 +175,22 @@ discard block |
||
175 | 175 | $objMod = new $modName($this->db); |
176 | 176 | if ($objMod) |
177 | 177 | { |
178 | - $result=0; |
|
179 | - |
|
180 | - if (method_exists($objMod, 'runTrigger')) // New method to implement |
|
181 | - { |
|
182 | - //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
|
183 | - $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
184 | - } |
|
185 | - elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
|
186 | - { |
|
187 | - dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
|
188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
189 | - } |
|
190 | - else |
|
191 | - { |
|
192 | - dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); |
|
193 | - } |
|
178 | + $result=0; |
|
179 | + |
|
180 | + if (method_exists($objMod, 'runTrigger')) // New method to implement |
|
181 | + { |
|
182 | + //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
|
183 | + $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
184 | + } |
|
185 | + elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
|
186 | + { |
|
187 | + dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
|
188 | + $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
189 | + } |
|
190 | + else |
|
191 | + { |
|
192 | + dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | if ($result > 0) |
196 | 196 | { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | else |
218 | - { |
|
218 | + { |
|
219 | 219 | dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR); |
220 | 220 | } |
221 | 221 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); |
255 | 255 | if (is_array($forcedirtriggers)) |
256 | 256 | { |
257 | - $dirtriggers=$forcedirtriggers; |
|
257 | + $dirtriggers=$forcedirtriggers; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | foreach($dirtriggers as $reldir) |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | { |
275 | 275 | if (preg_match('/\.back$/',$file)) continue; |
276 | 276 | |
277 | - $part1=$reg[1]; |
|
278 | - $part2=$reg[2]; |
|
279 | - $part3=$reg[3]; |
|
277 | + $part1=$reg[1]; |
|
278 | + $part2=$reg[2]; |
|
279 | + $part3=$reg[3]; |
|
280 | 280 | |
281 | 281 | $modName = 'Interface'.ucfirst($reg[3]); |
282 | 282 | //print "file=$file"; print "modName=$modName"; exit; |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | |
318 | 318 | if (! class_exists($modName)) |
319 | 319 | { |
320 | - print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
|
321 | - continue; |
|
320 | + print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
|
321 | + continue; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | $objMod = new $modName($db); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $triggers[$j]['module']=strtolower($module); |
341 | 341 | } |
342 | 342 | |
343 | - // We set info of modules |
|
343 | + // We set info of modules |
|
344 | 344 | $triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); |
345 | 345 | $triggers[$j]['file'] = $files[$key]; |
346 | 346 | $triggers[$j]['fullpath'] = $fullpath[$key]; |
@@ -26,63 +26,63 @@ |
||
26 | 26 | */ |
27 | 27 | class GoogleAPI |
28 | 28 | { |
29 | - /** |
|
29 | + /** |
|
30 | 30 | * @var DoliDB Database handler. |
31 | 31 | */ |
32 | 32 | public $db; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string Error code (or message) |
|
36 | - */ |
|
37 | - public $error=''; |
|
34 | + /** |
|
35 | + * @var string Error code (or message) |
|
36 | + */ |
|
37 | + public $error=''; |
|
38 | 38 | |
39 | - public $key; |
|
39 | + public $key; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
44 | - * @param DoliDB $db Database handler |
|
45 | - * @param string $key Google key |
|
46 | - */ |
|
47 | - function __construct($db,$key) |
|
48 | - { |
|
49 | - $this->db=$db; |
|
50 | - $this->key=$key; |
|
51 | - } |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | + * @param DoliDB $db Database handler |
|
45 | + * @param string $key Google key |
|
46 | + */ |
|
47 | + function __construct($db,$key) |
|
48 | + { |
|
49 | + $this->db=$db; |
|
50 | + $this->key=$key; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Return geo coordinates of an address |
|
56 | - * |
|
57 | - * @param string $address Address |
|
58 | - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
59 | - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
60 | - * @return string Coordinates |
|
61 | - */ |
|
62 | - function getGeoCoordinatesOfAddress($address) |
|
63 | - { |
|
64 | - global $conf; |
|
54 | + /** |
|
55 | + * Return geo coordinates of an address |
|
56 | + * |
|
57 | + * @param string $address Address |
|
58 | + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
59 | + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
60 | + * @return string Coordinates |
|
61 | + */ |
|
62 | + function getGeoCoordinatesOfAddress($address) |
|
63 | + { |
|
64 | + global $conf; |
|
65 | 65 | |
66 | - $i=0; |
|
66 | + $i=0; |
|
67 | 67 | |
68 | - // Desired address |
|
69 | - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
68 | + // Desired address |
|
69 | + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
70 | 70 | |
71 | - // Retrieve the URL contents |
|
72 | - $page = file_get_contents($urladdress); |
|
71 | + // Retrieve the URL contents |
|
72 | + $page = file_get_contents($urladdress); |
|
73 | 73 | |
74 | - $code = strstr($page, '<coordinates>'); |
|
75 | - $code = strstr($code, '>'); |
|
76 | - $val=strpos($code, "<"); |
|
77 | - $code = substr($code, 1, $val-1); |
|
78 | - //print $code; |
|
79 | - //print "<br>"; |
|
80 | - $latitude = substr($code, 0, strpos($code, ",")); |
|
81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
74 | + $code = strstr($page, '<coordinates>'); |
|
75 | + $code = strstr($code, '>'); |
|
76 | + $val=strpos($code, "<"); |
|
77 | + $code = substr($code, 1, $val-1); |
|
78 | + //print $code; |
|
79 | + //print "<br>"; |
|
80 | + $latitude = substr($code, 0, strpos($code, ",")); |
|
81 | + $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
82 | 82 | |
83 | - // Output the coordinates |
|
84 | - //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
83 | + // Output the coordinates |
|
84 | + //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
85 | 85 | |
86 | - $i++; |
|
87 | - } |
|
86 | + $i++; |
|
87 | + } |
|
88 | 88 | } |