29require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
35$langs->loadLangs(array(
"bills",
"accountancy"));
37$action =
GETPOST(
'action',
'aZ09');
38$cancel =
GETPOST(
'cancel',
'alpha');
39$backtopage =
GETPOST(
'backtopage',
'alpha');
45if (!isModEnabled(
'accounting')) {
48if ($user->socid > 0) {
51if (!$user->hasRight(
'accounting',
'bind',
'write')) {
60if ($action ==
'ventil' && $user->hasRight(
'accounting',
'bind',
'write')) {
62 if ($codeventil < 0) {
66 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"facture_fourn_det";
67 $sql .=
" SET fk_code_ventilation = ".((int) $codeventil);
68 $sql .=
" WHERE rowid = ".((int) $id);
70 $resql = $db->query($sql);
74 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
76 header(
"Location: ".$backtopage);
81 header(
"Location: ./lines.php");
91$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
93llxHeader(
"", $langs->trans(
'FicheVentilation'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-supplier page-card');
95if ($cancel == $langs->trans(
"Cancel")) {
100$form =
new Form($db);
105 $sql =
"SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
106 $sql .=
" p.rowid as product_id, p.ref as product_ref, p.label as product_label,";
108 $sql .=
" ppe.accountancy_code_buy as code_buy,";
110 $sql .=
" p.accountancy_code_buy as code_buy,";
112 $sql .=
" aa.account_number, aa.label";
113 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as l";
114 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
116 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
118 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
119 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
120 $sql .=
" WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id);
121 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
123 dol_syslog(
"/accounting/supplier/card.php", LOG_DEBUG);
124 $result = $db->query($sql);
127 $num_lines = $db->num_rows($result);
131 $objp = $db->fetch_object($result);
133 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" method="post">'.
"\n";
134 print
'<input type="hidden" name="token" value="'.newToken().
'">';
135 print
'<input type="hidden" name="action" value="ventil">';
136 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).
'">';
138 print
load_fiche_titre($langs->trans(
'SuppliersVentilation'),
'',
'title_accountancy');
142 print
'<table class="border centpercent">';
145 print
'<tr><td>'.$langs->trans(
"BillsSuppliers").
'</td>';
146 $facturefournisseur_static->ref = $objp->ref;
147 $facturefournisseur_static->id = $objp->facid;
148 print
'<td>'.$facturefournisseur_static->getNomUrl(1).
'</td>';
151 print
'<tr><td>'.$langs->trans(
"Description").
'</td>';
152 print
'<td>'.dolPrintHTML($objp->description).
'</td></tr>';
154 print
'<tr><td>'.$langs->trans(
"ProductLabel").
'</td>';
155 print
'<td>'.dol_trunc($objp->product_label, 24).
'</td></tr>';
157 print
'<tr><td>'.$langs->trans(
"Account").
'</td><td>';
158 print $formaccounting->select_account($objp->fk_code_ventilation,
'codeventil', 1);
165 print
'<div class="center">';
166 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
167 print
' ';
168 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
179 print
"Error ID incorrect";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage suppliers invoices.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.