diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 18991f66bba..2c285903cbe 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (! $user->rights->societe->lire) accessforbidden(); @@ -65,6 +66,7 @@ $formfile = new FormFile($db); $companystatic=new Societe($db); if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); +if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); llxHeader(); @@ -261,6 +263,84 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $db->free($resql); } + else + { + dol_print_error($db); + } +} + + +/* + * Draft suppliers orders + */ +if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +{ + $langs->load("orders"); + + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= ", s.code_fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE cf.fk_soc = s.rowid"; + $sql.= " AND cf.fk_statut = 0"; + $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND cf.fk_soc = ".$socid; + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + $var=!$var; + print '"; + } + } + print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; + $supplierorderstatic->id=$obj->rowid; + $supplierorderstatic->ref=$obj->ref; + $supplierorderstatic->ref_supplier=$obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + print $supplierorderstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."

"; + + $db->free($resql); + } else { + dol_print_error($db); + } }