dolibarr  9.0.0
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
4  * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
5  * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
6  * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
29 require '../../main.inc.php';
30 
31 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("bills","accountancy"));
36 
37 $action = GETPOST('action', 'alpha');
38 $cancel = GETPOST('cancel', 'alpha');
39 $backtopage = GETPOST('backtopage', 'alpha');
40 
41 $codeventil = GETPOST('codeventil');
42 $id = GETPOST('id');
43 
44 // Security check
45 if ($user->societe_id > 0)
47 
48 
49 /*
50  * Actions
51  */
52 
53 if ($action == 'ventil' && $user->rights->accounting->bind->write)
54 {
55  if (! $cancel)
56  {
57  if ($codeventil < 0) $codeventil = 0;
58 
59  $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
60  $sql .= " SET fk_code_ventilation = " . $codeventil;
61  $sql .= " WHERE rowid = " . $id;
62 
63  $resql = $db->query($sql);
64  if (! $resql) {
65  setEventMessages($db->lasterror(), null, 'errors');
66  }
67  else
68  {
69  setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
70  if ($backtopage)
71  {
72  header("Location: ".$backtopage);
73  exit();
74  }
75  }
76  } else {
77  header("Location: ./lines.php");
78  exit();
79  }
80 }
81 
82 
83 
84 /*
85  * View
86  */
87 llxHeader("", $langs->trans('FicheVentilation'));
88 
89 if ($cancel == $langs->trans("Cancel")) {
90  $action = '';
91 }
92 
93 // Create
94 $form = new Form($db);
95 $facturefournisseur_static = new FactureFournisseur($db);
96 $formaccounting = new FormAccounting($db);
97 
98 if (! empty($id)) {
99  $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
100  $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
101  $sql .= ", aa.account_number, aa.label";
102  $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
103  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
104  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
105  $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
106  $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
107  $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
108 
109  dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
110  $result = $db->query($sql);
111 
112  if ($result) {
113  $num_lines = $db->num_rows($result);
114  $i = 0;
115 
116  if ($num_lines) {
117  $objp = $db->fetch_object($result);
118 
119  print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
120  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
121  print '<input type="hidden" name="action" value="ventil">';
122  print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
123 
124  print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup');
125 
126  dol_fiche_head();
127 
128  print '<table class="border" width="100%">';
129 
130  // ref invoice
131  print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
132  $facturefournisseur_static->ref = $objp->facnumber;
133  $facturefournisseur_static->id = $objp->facid;
134  print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
135  print '</tr>';
136 
137  print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
138  print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
139  print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
140  print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
141  print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
142  print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
143  print '</td></tr>';
144  print '</table>';
145 
146  dol_fiche_end();
147 
148  print '<div class="center">';
149  print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
150  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
151  print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
152  print '</div>';
153 
154  print '</form>';
155  } else {
156  print "Error";
157  }
158  } else {
159  print "Error";
160  }
161 } else {
162  print "Error ID incorrect";
163 }
164 
165 // End of page
166 llxFooter();
167 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
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:1053
Class to manage suppliers invoices.
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 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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
if($_POST["cancel"]==$langs->trans("Cancel") &&! $id) if($action=='add' && $_POST["cancel"]<> $langs->trans("Cancel")) if($action=='delete') if($id) $form
Actions.
Definition: card.php:153
Class to manage generation of HTML components for accounting management.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.