25require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
31$langs->loadLangs(array(
"bills",
"accountancy"));
33$action =
GETPOST(
'action',
'aZ09');
34$cancel =
GETPOST(
'cancel',
'alpha');
35$backtopage =
GETPOST(
'backtopage',
'alpha');
37$codeventil =
GETPOST(
'codeventil',
'int');
41if (!isModEnabled(
'accounting')) {
44if ($user->socid > 0) {
47if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
57if ($action ==
'ventil' && $user->hasRight(
'accounting',
'bind',
'write')) {
59 if ($codeventil < 0) {
63 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"facturedet";
64 $sql .=
" SET fk_code_ventilation = ".((int) $codeventil);
65 $sql .=
" WHERE rowid = ".((int) $id);
67 $resql = $db->query($sql);
71 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
73 header(
"Location: ".$backtopage);
78 header(
"Location: ./lines.php");
88llxHeader(
"", $langs->trans(
'FicheVentilation'));
90if ($cancel == $langs->trans(
"Cancel")) {
98$facture_static =
new Facture($db);
102 $sql =
"SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,";
103 $sql .=
" l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,";
104 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
105 $sql .=
" ppe.accountancy_code_sell as code_sell,";
107 $sql .=
" p.accountancy_code_sell as code_sell,";
109 $sql .=
" l.fk_code_ventilation, aa.account_number, aa.label";
110 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as l";
111 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
112 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
113 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
115 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
116 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = l.fk_facture";
117 $sql .=
" WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id);
118 $sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
")";
120 dol_syslog(
"/accounting/customer/card.php", LOG_DEBUG);
121 $result = $db->query($sql);
124 $num_lines = $db->num_rows($result);
128 $objp = $db->fetch_object($result);
130 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="post">'.
"\n";
131 print
'<input type="hidden" name="token" value="'.newToken().
'">';
132 print
'<input type="hidden" name="action" value="ventil">';
133 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).
'">';
135 print
load_fiche_titre($langs->trans(
'CustomersVentilation'),
'',
'title_accountancy');
139 print
'<table class="border centpercent">';
142 print
'<tr><td>'.$langs->trans(
"Invoice").
'</td>';
143 $facture_static->ref = $objp->ref;
144 $facture_static->id = $objp->facid;
145 print
'<td>'.$facture_static->getNomUrl(1).
'</td>';
148 print
'<tr><td width="20%">'.$langs->trans(
"Line").
'</td>';
149 print
'<td>'.nl2br($objp->description).
'</td></tr>';
150 print
'<tr><td width="20%">'.$langs->trans(
"Account").
'</td><td>';
151 print $formaccounting->select_account($objp->fk_code_ventilation,
'codeventil', 1);
157 print
'<div class="center">';
158 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
159 print
' ';
160 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
171 print
"Error ID incorrect";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.