27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32$langs->loadLangs(array(
"suppliers",
"orders",
"companies"));
37 $socid = $user->socid;
48$companystatic =
new Societe($db);
50llxHeader(
"", $langs->trans(
"SuppliersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-index');
57print
'<div class="fichecenter"><div class="fichethirdleft">';
61$sql =
"SELECT count(cf.rowid), cf.fk_statut";
62$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf,";
63$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
64if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
65 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
67$sql .=
" WHERE cf.fk_soc = s.rowid ";
68if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
69 $sql .=
" AND sc.fk_user = ".((int) $user->id);
71$sql .=
" AND cf.entity = ".$conf->entity;
72$sql .=
" GROUP BY cf.fk_statut";
74$resql = $db->query($sql);
76 $num = $db->num_rows($resql);
79 print
'<table class="noborder centpercent">';
80 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Orders").
'</td><td class="center">'.$langs->trans(
"Nb").
'</td><td> </td>';
84 $row = $db->fetch_row($resql);
86 print
'<tr class="oddeven">';
87 print
'<td>'.$commandestatic->LibStatut($row[1]).
'</td>';
88 print
'<td class="center">'.$row[0].
'</td>';
89 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?statut='.$row[1].
'">'.$commandestatic->LibStatut($row[1], 3).
'</a></td>';
103if (isModEnabled(
"supplier_order")) {
104 $langs->load(
"orders");
106 $sql =
"SELECT cf.rowid, cf.ref, cf.total_ttc,";
107 $sql .=
" s.nom as name, s.rowid as socid";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
109 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
110 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
111 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
113 $sql .=
" WHERE cf.fk_soc = s.rowid";
114 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
115 $sql .=
" AND sc.fk_user = ".((int) $user->id);
117 $sql .=
" AND cf.entity = ".$conf->entity;
118 $sql .=
" AND cf.fk_statut = 0";
120 $sql .=
" AND cf.fk_soc = ".((int) $socid);
123 $resql = $db->query($sql);
126 $num = $db->num_rows($resql);
128 print
'<table class="noborder centpercent">';
129 print
'<tr class="liste_titre">';
130 print
'<td colspan="3">'.$langs->trans(
"DraftOrders").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
134 $obj = $db->fetch_object($resql);
136 print
'<tr class="oddeven"><td class="nowrap">';
137 $commandestatic->id = $obj->rowid;
138 $commandestatic->ref = $obj->ref;
139 print $commandestatic->getNomUrl(1,
'', 16);
141 print
'<td class="nowrap">';
142 $companystatic->id = $obj->socid;
143 $companystatic->name = $obj->name;
144 $companystatic->client = 0;
145 print $companystatic->getNomUrl(1,
'', 16);
147 print
'<td class="right nowrap">'.price($obj->total_ttc).
'</td></tr>';
149 $total += $obj->total_ttc;
152 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td colspan="2" class="right">'.
price($total).
"</td></tr>";
161if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
162 $sql =
"SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
163 $sql .=
", s.nom as name, s.rowid as socid";
164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
165 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
166 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
167 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
169 $sql .=
" WHERE s.rowid = ff.fk_soc";
170 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
171 $sql .=
" AND sc.fk_user = ".((int) $user->id);
173 $sql .=
" AND ff.entity = ".$conf->entity;
174 $sql .=
" AND ff.fk_statut = 0";
176 $sql .=
" AND f.fk_soc = ".((int) $socid);
179 $resql = $db->query($sql);
182 $num = $db->num_rows($resql);
184 print
'<table class="noborder centpercent">';
185 print
'<tr class="liste_titre">';
186 print
'<td colspan="3">'.$langs->trans(
"DraftBills").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
190 while ($i < $num && $i < 20) {
191 $obj = $db->fetch_object($resql);
193 print
'<tr class="oddeven"><td class="nowrap">';
194 $facturestatic->ref = $obj->ref;
195 $facturestatic->id = $obj->rowid;
196 $facturestatic->type = $obj->type;
197 print $facturestatic->getNomUrl(1,
'');
199 print
'<td class="nowrap">';
200 $companystatic->id = $obj->socid;
201 $companystatic->name = $obj->name;
202 $companystatic->client = 0;
203 print $companystatic->getNomUrl(1,
'', 16);
205 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
207 $tot_ttc += $obj->total_ttc;
211 print
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
212 print
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
225print
'</div><div class="fichetwothirdright">';
232$sql =
"SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur";
234 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
236 $sql .=
", s.code_compta_fournisseur";
238$sql .=
", st.libelle as stcomm";
239$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
241 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
243$sql .=
", ".MAIN_DB_PREFIX.
"c_stcomm as st";
244if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
245 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
247$sql .=
" WHERE s.fk_stcomm = st.id";
248$sql .=
" AND s.fournisseur = 1";
249$sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
250if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
251 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
254 $sql .=
" AND s.rowid = ".((int) $socid);
256$sql .=
" ORDER BY s.tms DESC";
257$sql .= $db->plimit($max, 0);
259$resql = $db->query($sql);
261 $langs->load(
"boxes");
262 $num = $db->num_rows($resql);
265 print
'<table class="noborder centpercent">';
266 print
'<tr class="liste_titre">';
267 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastSuppliers", min($max, $num)).
"</td>\n";
268 print
'<td class="right">'.$langs->trans(
"DateModification").
"</td>\n";
271 while ($obj = $db->fetch_object($resql)) {
272 print
'<tr class="oddeven">';
273 print
'<td><a href="card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowSupplier"),
"company").
'</a>';
274 print
" <a href=\"card.php?socid=".$obj->socid.
"\">".$obj->name.
"</a></td>\n";
275 print
'<td class="left">'.$obj->code_fournisseur.
' </td>';
276 print
'<td class="right">'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
290$companystatic->LoadSupplierCateg();
293if (count($companystatic->SupplierCategories)) {
296 print
'<table class="liste centpercent">';
297 print
'<tr class="liste_titre"><td colspan="2">';
298 print $langs->trans(
"Category");
299 print
"</td></tr>\n";
301 foreach ($companystatic->SupplierCategories as $rowid => $label) {
302 print
'<tr class="oddeven">'.
"\n";
304 $categstatic->id = $rowid;
305 $categstatic->ref = $label;
306 $categstatic->label = $label;
307 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.
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.