dolibarr  7.0.0-beta
orderstoinvoice.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
6  * Copyright (C) 2012 Andreu Bisquerra Gaya <jove@bisquerra.com>
7  * Copyright (C) 2012 David Rodriguez Martinez <davidrm146@gmail.com>
8  * Copyright (C) 2012-2017 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
10  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
34 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
38 require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php';
39 if (! empty($conf->projet->enabled)) {
40  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
41 }
42 
43 $langs->load('orders');
44 $langs->load('deliveries');
45 $langs->load('companies');
46 
47 if (! $user->rights->fournisseur->facture->creer)
49 
50 $id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST("facid")); // For backward compatibility
51 $ref = GETPOST('ref', 'alpha');
52 $action = GETPOST('action', 'alpha');
53 $confirm = GETPOST('confirm', 'alpha');
54 $sref = GETPOST('sref');
55 $sref_client = GETPOST('sref_client');
56 $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
57 $socid = GETPOST('socid', 'int');
58 $selected = GETPOST('orders_to_invoice');
59 $sortfield = GETPOST("sortfield", 'alpha');
60 $sortorder = GETPOST("sortorder", 'alpha');
61 $viewstatut = GETPOST('viewstatut');
62 
63 if (! $sortfield)
64  $sortfield = 'c.rowid';
65 if (! $sortorder)
66  $sortorder = 'DESC';
67 
68 $now = dol_now();
69 $date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server
70 $date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]);
71 $date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server
72 $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]);
73 
74 $extrafields = new ExtraFields($db);
75 
76 // fetch optionals attributes and labels
77 $extralabels=$extrafields->fetch_name_optionals_label('facture_fourn');
78 
79 if ($action == 'create')
80 {
81  if (! is_array($selected))
82  {
83  $error++;
84  setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors');
85  } else {
86  $origin = GETPOST('origin');
87  $originid = GETPOST('originid');
88  }
89 }
90 
91 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
92 include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
93 $hookmanager = new HookManager($db);
94 $hookmanager->initHooks(array('orderstoinvoicesupplier'));
95 
96 
97 /*
98  * Actions
99  */
100 
101 if (($action == 'create' || $action == 'add') && ! $error) {
102 
103  require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
104  if (! empty($conf->projet->enabled))
105  require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
106 
107  $langs->load('bills');
108  $langs->load('products');
109  $langs->load('main');
110  if (isset($_GET['orders_to_invoice'])) {
111  $orders_id = GETPOST('orders_to_invoice','',1);
112  $n = count($orders_id);
113  $i = 0;
114 
115  $originid = $orders_id[0];
116  $_GET['originid'] = $orders_id[0];
117  }
118  if (isset($_POST['orders_to_invoice'])) {
119  $orders_id = GETPOST('orders_to_invoice','',2);
120  $nn = count($orders_id);
121  $ii = 0;
122 
123  $originid = $orders_id[0];
124  $_POST['originid'] = $orders_id[0];
125  }
126 
127  $projectid = GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0;
128  $lineid = GETPOST('lineid', 'int');
129  $userid = GETPOST('userid', 'int');
130  $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref') : GETPOST('search_ref');
131 
132  // Security check
133  if ($user->societe_id)
134  $socid = $user->societe_id;
135  $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
136 
137  $usehm = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
138  $object = new FactureFournisseur($db);
139 
140  // Insert new invoice in database
141  if ($action == 'add' && $user->rights->fournisseur->facture->creer) {
142  $object->socid = GETPOST('socid');
143  $db->begin();
144  $error = 0;
145 
146  // Standard or deposit or proforma invoice
147  $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
148  if (empty($datefacture)) {
149  $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
150  }
151  if (! $error) {
152  $object->ref = GETPOST('ref');
153  $object->ref_supplier = GETPOST('ref_supplier');
154  $object->socid = GETPOST('socid','int');
155  $object->libelle = GETPOST('libelle');
156  $object->date = $datefacture;
157  $object->date_echeance = $datedue;
158  $object->note_public = GETPOST('note_public','none');
159  $object->note_private = GETPOST('note_private','none');
160  $object->cond_reglement_id = GETPOST('cond_reglement_id');
161  $object->mode_reglement_id = GETPOST('mode_reglement_id');
162  $projectid = GETPOST('projectid');
163  if ($projectid > 0)
164  $object->fk_project = $projectid;
165 
166  // Auto calculation of date due if not filled by user
167  if (empty($object->date_echeance))
168  $object->date_echeance = $object->calculate_date_lim_reglement();
169 
170  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
171  if ($ret < 0) $error++;
172 
173  if ($_POST['origin'] && $_POST['originid']) {
174  $linked_orders_ids=array();
175  foreach ( $orders_id as $origin => $origin_id ) {
176  $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]);
177  $linked_orders_ids[]=$origin_id;
178  }
179  $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids);
180  $id = $object->create($user);
181 
182  if ($id > 0) {
183  while ( $ii < $nn ) {
184  $objectsrc = new CommandeFournisseur($db);
185  dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
186  $result = $objectsrc->fetch($orders_id[$ii]);
187  if ($result > 0) {
188  $lines = $objectsrc->lines;
189  if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) {
190  $objectsrc->fetch_lines();
191  $lines = $objectsrc->lines;
192  }
193  $fk_parent_line = 0;
194  $num = count($lines);
195  for($i = 0; $i < $num; $i ++) {
196  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
197 
198  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
199  $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
200 
201  // Dates
202  // TODO mutualiser
203  $date_start = $lines[$i]->date_debut_prevue;
204  if ($lines[$i]->date_debut_reel)
205  $date_start = $lines[$i]->date_debut_reel;
206  if ($lines[$i]->date_start)
207  $date_start = $lines[$i]->date_start;
208  $date_end = $lines[$i]->date_fin_prevue;
209  if ($lines[$i]->date_fin_reel)
210  $date_end = $lines[$i]->date_fin_reel;
211  if ($lines[$i]->date_end)
212  $date_end = $lines[$i]->date_end;
213 
214  // Reset fk_parent_line for no child products and special product
215  if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
216  $fk_parent_line = 0;
217  }
218  // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
219  $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit);
220 
221  if ($result > 0) {
222  $lineid = $result;
223  } else {
224  $lineid = 0;
225  $error ++;
226  break;
227  }
228  // Defined the new fk_parent_line
229  if ($result > 0 && $lines[$i]->product_type == 9) {
230  $fk_parent_line = $result;
231  }
232  }
233  } else {
234  $mesgs[] = $objectsrc->error;
235  $error ++;
236  }
237  $ii ++;
238  }
239  } else {
240  $mesgs[] = $object->error;
241  $error ++;
242  }
243  }
244  }
245 
246  // End of object creation, we show it
247  if ($id > 0 && ! $error) {
248 
249  foreach($orders_id as $fk_supplier_order) {
250  $supplier_order = new CommandeFournisseur($db);
251  if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5)
252  {
253  if ($supplier_order->classifyBilled($user) < 0)
254  {
255  $db->rollback();
256  $action = 'create';
257  $_GET["origin"] = $_POST["origin"];
258  $_GET["originid"] = $_POST["originid"];
259  $mesgs[] = '<div class="error">' . $object->error . '</div>';
260 
261  $error++;
262  break;
263  }
264 
265  }
266  }
267 
268  if(!$error) {
269  $db->commit();
270  header('Location: ' . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $id);
271  exit();
272  }
273 
274  } else {
275  $db->rollback();
276  $action = 'create';
277  $_GET["origin"] = $_POST["origin"];
278  $_GET["originid"] = $_POST["originid"];
279  $mesgs[] = '<div class="error">' . $object->error . '</div>';
280  }
281  }
282 }
283 
284 /*
285  * View
286  */
287 
288 $html = new Form($db);
289 $htmlother = new FormOther($db);
290 $formfile = new FormFile($db);
291 $companystatic = new Societe($db);
292 
293 // Mode creation
294 if ($action == 'create' && !$error) {
295 
296  llxHeader();
297  print load_fiche_titre($langs->trans('NewBill'));
298 
299  $soc = new Societe($db);
300  if ($socid)
301  $res = $soc->fetch($socid);
302  if ($res) {
303  $cond_reglement_id = $soc->cond_reglement_id;
304  $mode_reglement_id = $soc->mode_reglement_id;
305  }
306  $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : '';
307 
308  print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
309  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
310  print '<input type="hidden" name="action" value="add">';
311  print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n";
312  print '<input name="facnumber" type="hidden" value="provisoire">';
313  print '<input name="ref_client" type="hidden" value="' . $ref_client . '">';
314  print '<input name="ref_int" type="hidden" value="' . $ref_int . '">';
315  print '<input type="hidden" name="origin" value="' . GETPOST('origin') . '">';
316  print '<input type="hidden" name="originid" value="' . GETPOST('originid') . '">';
317  print '<table class="border" width="100%">';
318 
319  // Ref
320  print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans('Draft') . '</td></tr>';
321 
322  // Ref supplier
323  print '<tr><td class="fieldrequired">' . $langs->trans('RefSupplier') . '</td><td><input name="ref_supplier" value="' . dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier','alpha', 2) : '') . '" type="text"></td>';
324  print '</tr>';
325 
326  // Third party
327  print '<tr><td class="fieldrequired">' . $langs->trans('Customer') . '</td><td colspan="2">';
328  print $soc->getNomUrl(1);
329  print '<input type="hidden" name="socid" value="' . $soc->id . '">';
330  print '</td>';
331  print '</tr>' . "\n";
332 
333  // Date invoice
334  print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
335  $html->select_date('', '', '', '', '', "add", 1, 1);
336  print '</td></tr>';
337  // Payment term
338  print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">';
339  $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
340  print '</td></tr>';
341  // Payment mode
342  print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
343  $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
344  print '</td></tr>';
345  // Project
346  if (! empty($conf->projet->enabled)) {
347  $formproject = new FormProjets($db);
348 
349  $langs->load('projects');
350  print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
351  $formproject->select_projects($soc->id, $projectid, 'projectid');
352  print '</td></tr>';
353  }
354 
355  $objectsrc = new CommandeFournisseur($db);
356  $listoforders = array ();
357  foreach ( $selected as $sel ) {
358  $result = $objectsrc->fetch($sel);
359  if ($result > 0) {
360  $listoforders[] = $objectsrc->ref;
361  }
362  }
363 
364  // Other attributes
365  $parameters = array (
366  'objectsrc' => $objectsrc,
367  'idsrc' => $listoforders,
368  'colspan' => ' colspan="2"',
369  'cols'=>2
370  );
371  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
372  print $hookmanager->resPrint;
373 
374  if (empty($reshook) && ! empty($extrafields->attribute_label))
375  {
376  $object=new FactureFournisseur($db);
377  print $object->showOptionals($extrafields,'edit');
378  }
379 
380  // Modele PDF
381  print '<tr><td>' . $langs->trans('Model') . '</td>';
382  print '<td>';
384  print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF);
385  print "</td></tr>";
386 
387  // Public note
388  print '<tr>';
389  print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
390  print '<td valign="top" colspan="2">';
391  print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">';
392 
393  print $langs->trans("Orders") . ": " . implode(', ', $listoforders);
394 
395  print '</textarea></td></tr>';
396  // Private note
397  if (empty($user->societe_id)) {
398  print '<tr>';
399  print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
400  print '<td valign="top" colspan="2">';
401  print '<textarea name="note" wrap="soft" cols="70" rows="' . ROWS_3 . '">';
402 
403  print '</textarea></td></tr>';
404  }
405 
406  print '</table>';
407 
408  while ( $i < $n ) {
409  print '<input type="hidden" name="orders_to_invoice[]" value="' . $orders_id[$i] . '">';
410 
411  $i ++;
412  }
413 
414  // Button "Create Draft"
415  print '<br><div class="center"><input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '" /></div>';
416  print "</form>\n";
417 
418  print '</td></tr>';
419  print "</table>\n";
420 }
421 
422 // Mode liste
423 if (($action != 'create' && $action != 'add') && !$error) {
424  llxHeader();
425  ?>
426  <script type="text/javascript">
427  jQuery(document).ready(function() {
428  jQuery("#checkall").click(function() {
429  jQuery(".checkformerge").prop('checked', true);
430  });
431  jQuery("#checknone").click(function() {
432  jQuery(".checkformerge").prop('checked', false);
433  });
434  });
435  </script>
436 <?php
437 
438  $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
439  $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
440  $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s';
441  $sql .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c';
442  if (! $user->rights->societe->client->voir && ! $socid)
443  $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
444  $sql .= ' WHERE c.entity = ' . $conf->entity;
445  $sql .= ' AND c.fk_soc = s.rowid';
446 
447  // Show orders with status validated, shipping started and delivered (well any order we can bill)
448  $sql .= " AND c.fk_statut IN (5)";
449  $sql .= " AND c.billed = 0";
450 
451  // Find order that are not already invoiced
452  //No need due to the billed status
453  //$sql .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
454 
455  if ($socid)
456  $sql .= ' AND s.rowid = ' . $socid;
457  if (! $user->rights->societe->client->voir && ! $socid)
458  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
459  if ($sref) {
460  $sql .= natural_search("c.ref", $sref);
461  }
462  if ($sall) {
463  $sql .= natural_search(array("c.ref","c.note"), $sall);
464  }
465 
466  // Date filter
467  if ($date_start && $date_end)
468  $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "' AND c.date_commande <= '" . $db->idate($date_end) . "'";
469  if ($date_starty && $date_endy)
470  $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "' AND c.date_livraison <= '" . $db->idate($date_endy) . "'";
471 
472  if (! empty($sref_client)) {
473  $sql .= natural_search('c.ref_supplier', $sref_client);
474  }
475  $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder;
476  dol_syslog('fourn/commande/ordertoinvoice.php sql=' . $sql);
477  $resql = $db->query($sql);
478 
479  if ($resql) {
480  if ($socid) {
481  $soc = new Societe($db);
482  $soc->fetch($socid);
483  }
484  $title = $langs->trans('ListOfSupplierOrders');
485  $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort');
486  $num = $db->num_rows($resql);
488  $i = 0;
489  $period = $html->select_date($date_start, 'date_start', 0, 0, 1, '', 1, 0, 1) . ' - ' . $html->select_date($date_end, 'date_end', 0, 0, 1, '', 1, 0, 1);
490  $periodely = $html->select_date($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0, 1) . ' - ' . $html->select_date($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0, 1);
491 
492  if (! empty($socid)) {
493  // Company
494  $companystatic->id = $socid;
495  $companystatic->nom = $soc->nom;
496  print '<h3>' . $companystatic->getNomUrl(1, 'customer') . '</h3>';
497  }
498 
499  print '<form name="orders2invoice" method="GET" action="orderstoinvoice.php">';
500  print '<input type="hidden" name="socid" value="' . $socid . '">';
501  print '<table class="noborder" width="100%">';
502  print '<tr class="liste_titre">';
503  print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
504  print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
505  print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&amp;socid=' . $socid, 'align="center"', $sortfield, $sortorder);
506  print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&amp;socid=' . $socid, 'align="center"', $sortfield, $sortorder);
507  print_liste_field_titre('Status', '', '', '', '', 'align="right"');
508  print_liste_field_titre('GenerateBill', '', '', '', '', 'align="center"');
509  print "</tr>\n";
510 
511  // Lignes des champs de filtre
512  print '<tr class="liste_titre">';
513  print '<td class="liste_titre">';
514  // REF
515  print '<input class="flat" size="10" type="text" name="sref" value="' . $sref . '">';
516  print '</td>';
517  // print '<td class="liste_titre">';
518  print '<td class="liste_titre" align="left">';
519  print '<input class="flat" type="text" size="10" name="sref_client" value="' . $sref_client . '">';
520  print '</td>';
521 
522  // DATE ORDER
523  print '<td class="liste_titre" align="center">';
524  print $period;
525  print '</td>';
526 
527  // DATE DELIVERY
528  print '<td class="liste_titre" align="center">';
529  print $periodely;
530  print '</td>';
531 
532  // SEARCH BUTTON
533  print '<td align="right" class="liste_titre">';
534  print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
535  print '</td>';
536 
537  // ALL/NONE
538  print '<td class="liste_titre" align="center">';
539  if ($conf->use_javascript_ajax)
540  print '<a href="#" id="checkall">' . $langs->trans("All") . '</a> / <a href="#" id="checknone">' . $langs->trans("None") . '</a>';
541  print '</td>';
542 
543  print '</td></tr>';
544 
545  $var = True;
546  $generic_commande = new CommandeFournisseur($db);
547 
548  while ( $i < $num ) {
549  $objp = $db->fetch_object($resql);
550  $var = ! $var;
551  print '<tr ' . $bc[$var] . '>';
552  print '<td class="nowrap">';
553 
554  $generic_commande->id = $objp->rowid;
555  $generic_commande->ref = $objp->ref;
556 
557  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
558  print '<td class="nobordernopadding nowrap">';
559  print $generic_commande->getNomUrl(1, $objp->fk_statut);
560  print '</td>';
561 
562  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
563  $filename = dol_sanitizeFileName($objp->ref);
564  $filedir = $conf->fournisseur->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref);
565  $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid;
566  print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
567  print '</td></tr></table>';
568  print '</td>';
569 
570  print '<td>' . $objp->ref_supplier . '</td>';
571 
572  // Order date
573  print '<td align="center" nowrap>';
574  print dol_print_date($db->jdate($objp->date_commande), 'day');
575  print '</td>';
576 
577  // Delivery date
578  print '<td align="center" nowrap>';
579  print dol_print_date($db->jdate($objp->date_livraison), 'day');
580  print '</td>';
581 
582  // Statut
583  print '<td align="right" class="nowrap">' . $generic_commande->LibStatut($objp->fk_statut, 5) . '</td>';
584 
585  // Checkbox
586  print '<td class="center">';
587  print '<input class="flat checkformerge" type="checkbox" name="orders_to_invoice[]" value="' . $objp->rowid . '">';
588  print '</td>';
589 
590  print '</tr>';
591 
592  $total = $total + $objp->price;
593  $subtotal = $subtotal + $objp->price;
594  $i ++;
595  }
596  print '</table>';
597 
598  /*
599  * Boutons actions
600  */
601  print '<div class="center">';
602  print '<div class="right">';
603  print '<input type="hidden" name="socid" value="' . $socid . '">';
604  print '<input type="hidden" name="action" value="create">';
605  print '<input type="hidden" name="origin" value="order_supplier"><br>';
606  // print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>';
607  print '<input type="submit" class="butAction" value="' . $langs->trans("GenerateBill") . '">';
608  print '</div>';
609  print '</div>';
610 
611  print '</form>';
612 
613  $db->free($resql);
614  } else {
615  print dol_print_error($db);
616  }
617 }
618 
619 dol_htmloutput_mesg($mesg, $mesgs);
620 
621 llxFooter();
622 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage suppliers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage standard extra fields.
Class to manage hooks.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage building of HTML components.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
Classe permettant la generation de composants html autre Only common components are here...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='gmt')
Return date for now.
Class to manage predefined suppliers products.
Class to offer components to list and upload files.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
type
Definition: viewcat.php:283
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.