26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
31 $langs->loadLangs(array(
"suppliers",
"orders",
"companies"));
34 $socid =
GETPOST(
"socid",
'int');
36 $socid = $user->socid;
47 $companystatic =
new Societe($db);
49 llxHeader(
"", $langs->trans(
"SuppliersArea"));
56 print
'<div class="fichecenter"><div class="fichethirdleft">';
60 $sql =
"SELECT count(cf.rowid), cf.fk_statut";
61 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf,";
62 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
63 if (empty($user->rights->societe->client->voir) && !$socid) {
64 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
66 $sql .=
" WHERE cf.fk_soc = s.rowid ";
67 if (empty($user->rights->societe->client->voir) && !$socid) {
68 $sql .=
" AND sc.fk_user = ".((int) $user->id);
70 $sql .=
" AND cf.entity = ".$conf->entity;
71 $sql .=
" GROUP BY cf.fk_statut";
75 $num = $db->num_rows(
$resql);
78 print
'<table class="noborder centpercent">';
79 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Orders").
'</td><td class="center">'.$langs->trans(
"Nb").
'</td><td> </td>';
83 $row = $db->fetch_row(
$resql);
85 print
'<tr class="oddeven">';
86 print
'<td>'.$commandestatic->LibStatut($row[1]).
'</td>';
87 print
'<td class="center">'.$row[0].
'</td>';
88 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?statut='.$row[1].
'">'.$commandestatic->LibStatut($row[1], 3).
'</a></td>';
102 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
103 $langs->load(
"orders");
105 $sql =
"SELECT cf.rowid, cf.ref, cf.total_ttc,";
106 $sql .=
" s.nom as name, s.rowid as socid";
107 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
108 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
109 if (empty($user->rights->societe->client->voir) && !$socid) {
110 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
112 $sql .=
" WHERE cf.fk_soc = s.rowid";
113 if (empty($user->rights->societe->client->voir) && !$socid) {
114 $sql .=
" AND sc.fk_user = ".((int) $user->id);
116 $sql .=
" AND cf.entity = ".$conf->entity;
117 $sql .=
" AND cf.fk_statut = 0";
119 $sql .=
" AND cf.fk_soc = ".((int) $socid);
122 $resql = $db->query($sql);
125 $num = $db->num_rows(
$resql);
127 print
'<table class="noborder centpercent">';
128 print
'<tr class="liste_titre">';
129 print
'<td colspan="3">'.$langs->trans(
"DraftOrders").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
133 $obj = $db->fetch_object(
$resql);
135 print
'<tr class="oddeven"><td class="nowrap">';
136 $commandestatic->id = $obj->rowid;
137 $commandestatic->ref = $obj->ref;
138 print $commandestatic->getNomUrl(1,
'', 16);
140 print
'<td class="nowrap">';
141 $companystatic->id = $obj->socid;
142 $companystatic->name = $obj->name;
143 $companystatic->client = 0;
144 print $companystatic->getNomUrl(1,
'', 16);
146 print
'<td class="right nowrap">'.price($obj->total_ttc).
'</td></tr>';
148 $total += $obj->total_ttc;
151 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td colspan="2" class="right">'.
price($total).
"</td></tr>";
160 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
161 $sql =
"SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type";
162 $sql .=
", s.nom as name, s.rowid as socid";
163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
164 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
165 if (empty($user->rights->societe->client->voir) && !$socid) {
166 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
168 $sql .=
" WHERE s.rowid = ff.fk_soc";
169 if (empty($user->rights->societe->client->voir) && !$socid) {
170 $sql .=
" AND sc.fk_user = ".((int) $user->id);
172 $sql .=
" AND ff.entity = ".$conf->entity;
173 $sql .=
" AND ff.fk_statut = 0";
175 $sql .=
" AND f.fk_soc = ".((int) $socid);
178 $resql = $db->query($sql);
181 $num = $db->num_rows(
$resql);
183 print
'<table class="noborder centpercent">';
184 print
'<tr class="liste_titre">';
185 print
'<td colspan="3">'.$langs->trans(
"DraftBills").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td></tr>';
189 while ($i < $num && $i < 20) {
190 $obj = $db->fetch_object(
$resql);
192 print
'<tr class="oddeven"><td class="nowrap">';
193 $facturestatic->ref = $obj->ref;
194 $facturestatic->id = $obj->rowid;
195 $facturestatic->type = $obj->type;
196 print $facturestatic->getNomUrl(1,
'');
198 print
'<td class="nowrap">';
199 $companystatic->id = $obj->socid;
200 $companystatic->name = $obj->name;
201 $companystatic->client = 0;
202 print $companystatic->getNomUrl(1,
'', 16);
204 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
206 $tot_ttc += $obj->total_ttc;
210 print
'<tr class="liste_total"><td class="left">'.$langs->trans(
"Total").
'</td>';
211 print
'<td colspan="2" class="right">'.price($tot_ttc).
'</td>';
224 print
'</div><div class="fichetwothirdright">';
231 $sql =
"SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur";
232 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
233 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
235 $sql .=
", s.code_compta_fournisseur";
237 $sql .=
", st.libelle as stcomm";
238 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
239 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
240 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
242 $sql .=
", ".MAIN_DB_PREFIX.
"c_stcomm as st";
243 if (empty($user->rights->societe->client->voir) && !$socid) {
244 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
246 $sql .=
" WHERE s.fk_stcomm = st.id";
247 $sql .=
" AND s.fournisseur = 1";
248 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
249 if (empty($user->rights->societe->client->voir) && !$socid) {
250 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
253 $sql .=
" AND s.rowid = ".((int) $socid);
255 $sql .=
" ORDER BY s.tms DESC";
256 $sql .= $db->plimit($max, 0);
258 $resql = $db->query($sql);
260 $langs->load(
"boxes");
261 $num = $db->num_rows(
$resql);
264 print
'<table class="noborder centpercent">';
265 print
'<tr class="liste_titre">';
266 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastSuppliers", min($max, $num)).
"</td>\n";
267 print
'<td class="right">'.$langs->trans(
"DateModification").
"</td>\n";
270 while ($obj = $db->fetch_object(
$resql)) {
271 print
'<tr class="oddeven">';
272 print
'<td><a href="card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowSupplier"),
"company").
'</a>';
273 print
" <a href=\"card.php?socid=".$obj->socid.
"\">".$obj->name.
"</a></td>\n";
274 print
'<td class="left">'.$obj->code_fournisseur.
' </td>';
275 print
'<td class="right">'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
289 $companystatic->LoadSupplierCateg();
292 if (count($companystatic->SupplierCategories)) {
295 print
'<table class="liste centpercent">';
296 print
'<tr class="liste_titre"><td colspan="2">';
297 print $langs->trans(
"Category");
298 print
"</td></tr>\n";
300 foreach ($companystatic->SupplierCategories as $rowid => $label) {
301 print
'<tr class="oddeven">'.
"\n";
303 $categstatic->id = $rowid;
304 $categstatic->ref = $label;
305 $categstatic->label = $label;
306 print $categstatic->getNomUrl(1);
320 print
'</div></div>';