28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41$langs->loadLangs(array(
"suppliers",
"orders",
"companies"));
46 $socid = $user->socid;
57$companystatic =
new Societe($db);
59llxHeader(
"", $langs->trans(
"SuppliersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-index');
66print
'<div class="fichecenter"><div class="fichethirdleft">';
70$sql =
"SELECT count(cf.rowid), cf.fk_statut";
71$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf,";
72$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
73if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
74 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
76$sql .=
" WHERE cf.fk_soc = s.rowid ";
77if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
78 $sql .=
" AND sc.fk_user = ".((int) $user->id);
80$sql .=
" AND cf.entity = ".$conf->entity;
81$sql .=
" GROUP BY cf.fk_statut";
83$resql = $db->query($sql);
85 $num = $db->num_rows($resql);
88 print
'<table class="noborder centpercent">';
89 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Orders").
'</td><td class="center">'.$langs->trans(
"Nb").
'</td><td> </td>';
93 $row = $db->fetch_row($resql);
95 print
'<tr class="oddeven">';
96 print
'<td>'.$commandestatic->LibStatut($row[1]).
'</td>';
97 print
'<td class="center">'.$row[0].
'</td>';
98 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?statut='.$row[1].
'">'.$commandestatic->LibStatut($row[1], 3).
'</a></td>';
112if (isModEnabled(
"supplier_order")) {
113 $langs->load(
"orders");
115 $sql =
"SELECT cf.rowid, cf.ref, cf.total_ttc,";
116 $sql .=
" s.nom as name, s.rowid as socid";
117 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
118 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
119 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
120 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
122 $sql .=
" WHERE cf.fk_soc = s.rowid";
123 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
124 $sql .=
" AND sc.fk_user = ".((int) $user->id);
126 $sql .=
" AND cf.entity = ".$conf->entity;
127 $sql .=
" AND cf.fk_statut = 0";
129 $sql .=
" AND cf.fk_soc = ".((int) $socid);
132 $resql = $db->query($sql);
135 $num = $db->num_rows($resql);
137 print
'<table class="noborder centpercent">';
138 print
'<tr class="liste_titre">';
139 print
'<td colspan="3">'.$langs->trans(
"DraftOrders").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
143 $obj = $db->fetch_object($resql);
145 print
'<tr class="oddeven"><td class="nowrap">';
146 $commandestatic->id = $obj->rowid;
147 $commandestatic->ref = $obj->ref;
148 print $commandestatic->getNomUrl(1,
'', 16);
150 print
'<td class="nowrap">';
151 $companystatic->id = $obj->socid;
152 $companystatic->name = $obj->name;
153 $companystatic->client = 0;
154 print $companystatic->getNomUrl(1,
'', 16);
156 print
'<td class="right nowrap">'.price($obj->total_ttc).
'</td></tr>';
158 $total += $obj->total_ttc;
161 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td colspan="2" class="right">'.
price($total).
"</td></tr>";
170if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
171 $sql =
"SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
172 $sql .=
", s.nom as name, s.rowid as socid";
173 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
174 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
175 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
176 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
178 $sql .=
" WHERE s.rowid = ff.fk_soc";
179 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
180 $sql .=
" AND sc.fk_user = ".((int) $user->id);
182 $sql .=
" AND ff.entity = ".$conf->entity;
183 $sql .=
" AND ff.fk_statut = 0";
185 $sql .=
" AND f.fk_soc = ".((int) $socid);
188 $resql = $db->query($sql);
191 $num = $db->num_rows($resql);
193 print
'<table class="noborder centpercent">';
194 print
'<tr class="liste_titre">';
195 print
'<td colspan="3">'.$langs->trans(
"DraftBills").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
199 while ($i < $num && $i < 20) {
200 $obj = $db->fetch_object($resql);
202 print
'<tr class="oddeven"><td class="nowrap">';
203 $facturestatic->ref = $obj->ref;
204 $facturestatic->id = $obj->rowid;
205 $facturestatic->type = $obj->type;
206 print $facturestatic->getNomUrl(1,
'');
208 print
'<td class="nowrap">';
209 $companystatic->id = $obj->socid;
210 $companystatic->name = $obj->name;
211 $companystatic->client = 0;
212 print $companystatic->getNomUrl(1,
'', 16);
214 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
216 $tot_ttc += $obj->total_ttc;
220 print
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
221 print
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
234print
'</div><div class="fichetwothirdright">';
241$sql =
"SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur";
243 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
245 $sql .=
", s.code_compta_fournisseur";
247$sql .=
", st.libelle as stcomm";
248$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
250 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
252$sql .=
", ".MAIN_DB_PREFIX.
"c_stcomm as st";
253if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
254 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
256$sql .=
" WHERE s.fk_stcomm = st.id";
257$sql .=
" AND s.fournisseur = 1";
258$sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
259if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
260 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
263 $sql .=
" AND s.rowid = ".((int) $socid);
265$sql .=
" ORDER BY s.tms DESC";
266$sql .= $db->plimit($max, 0);
268$resql = $db->query($sql);
270 $langs->load(
"boxes");
271 $num = $db->num_rows($resql);
274 print
'<table class="noborder centpercent">';
275 print
'<tr class="liste_titre">';
276 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastSuppliers", min($max, $num)).
"</td>\n";
277 print
'<td class="right">'.$langs->trans(
"DateModification").
"</td>\n";
280 while ($obj = $db->fetch_object($resql)) {
281 print
'<tr class="oddeven">';
282 print
'<td><a href="card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowSupplier"),
"company").
'</a>';
283 print
" <a href=\"card.php?socid=".$obj->socid.
"\">".$obj->name.
"</a></td>\n";
284 print
'<td class="left">'.$obj->code_fournisseur.
' </td>';
285 print
'<td class="right">'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
299$companystatic->LoadSupplierCateg();
302if (count($companystatic->SupplierCategories)) {
305 print
'<table class="liste centpercent">';
306 print
'<tr class="liste_titre"><td colspan="2">';
307 print $langs->trans(
"Category");
308 print
"</td></tr>\n";
310 foreach ($companystatic->SupplierCategories as $rowid => $label) {
311 print
'<tr class="oddeven">'.
"\n";
313 $categstatic->id = $rowid;
314 $categstatic->ref = $label;
315 $categstatic->label = $label;
316 print $categstatic->getNomUrl(1);
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 categories.
Class to manage predefined suppliers products.
Class to manage suppliers invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.