From bc669f1702cf9b6efb3a04cdd3e37520f2d0900c Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 9 Oct 2014 13:54:52 +0200 Subject: [PATCH 1/2] Merge --- htdocs/categories/viewcat.php | 82 +++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 14a63ffc837..c55f324ab06 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -38,7 +38,7 @@ $type=GETPOST('type'); $action=GETPOST('action'); $confirm=GETPOST('confirm'); $removeelem = GETPOST('removeelem','int'); -$elemid=GETPOST('elemid'); +$elemid=GETPOST('elemid'); if ($id == "") { @@ -121,32 +121,32 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } } -if ($type==0 && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) +if ($type==0 && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $newobject = new Product($db); - $result = $newobject->fetch($elemid); + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $newobject = new Product($db); + $result = $newobject->fetch($elemid); $elementtype = 'product'; // TODO Add into categ - $result=$object->add_type($newobject,$elementtype); - if ($result >= 0) - { - setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref)); - } - else - { - if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); - } - else - { - setEventMessages($object->error,$object->errors,'errors'); - } - } - -} + $result=$object->add_type($newobject,$elementtype); + if ($result >= 0) + { + setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref)); + } + else + { + if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); + } + else + { + setEventMessages($object->error,$object->errors,'errors'); + } + } + +} @@ -292,26 +292,26 @@ if ($object->type == 0) { $showclassifyform=1; $typeid=0; - // Form to add record into a category - if ($showclassifyform) - { + // Form to add record into a category + if ($showclassifyform) + { print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddProductServiceIntoCategory").'  '; - print $form->select_produits('','elemid','',0,0,-1,2,'',1); - print ''; - print '
'; - print '
'; - } + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddProductServiceIntoCategory").'  '; + print $form->select_produits('','elemid','',0,0,-1,2,'',1); + print ''; + print '
'; + print ''; + } print "
"; print "\n"; From 3a626d850397f86c355d514e0feffd3b53e58557 Mon Sep 17 00:00:00 2001 From: MAxime Kohlhaas Date: Sat, 25 Oct 2014 17:22:03 +0200 Subject: [PATCH 2/2] Add : statistics on supplier orders and invoices on home page --- .../class/fournisseur.commande.class.php | 41 +++++++++++++++++ .../fourn/class/fournisseur.facture.class.php | 42 +++++++++++++++++ htdocs/index.php | 46 ++++++++++++------- 3 files changed, 113 insertions(+), 16 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7983060490d..6c097cd6d5b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1923,6 +1923,47 @@ class CommandeFournisseur extends CommonOrder } } + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf, $user; + + $this->nb=array(); + $clause = "WHERE"; + + $sql = "SELECT count(co.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." co.entity = ".$conf->entity; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["supplier_orders"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 9c72319f74f..c7067410c41 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1606,6 +1606,48 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $xnbp*119.6; } + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @return int <0 if KO, >0 if OK + */ + function load_state_board() + { + global $conf, $user; + + $this->nb=array(); + + $clause = "WHERE"; + + $sql = "SELECT count(f.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." f.entity = ".$conf->entity; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["supplier_invoices"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + /** * Load an object from its id and create a new one in database * diff --git a/htdocs/index.php b/htdocs/index.php index 138ddc4e3a9..ebc6760252c 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -154,7 +154,9 @@ if (empty($user->societe_id)) ! empty($conf->propal->enabled) && $user->rights->propale->lire, ! empty($conf->commande->enabled) && $user->rights->commande->lire, ! empty($conf->facture->enabled) && $user->rights->facture->lire, - ! empty($conf->contrat->enabled) && $user->rights->contrat->activer); + ! empty($conf->contrat->enabled) && $user->rights->contrat->activer, + ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire, + ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire); // Class file containing the method load_state_board for each line $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php", DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php", @@ -165,7 +167,9 @@ if (empty($user->societe_id)) DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", - DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); + DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php", + DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php", + DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php"); // Name class containing the method load_state_board for each line $classes=array('Client', 'Prospect', @@ -173,10 +177,12 @@ if (empty($user->societe_id)) 'Adherent', 'Product', 'Service', - 'Propal', - 'Commande', - 'Facture', - 'Contrat'); + 'Propal', + 'Commande', + 'Facture', + 'Contrat', + 'CommandeFournisseur', + 'FactureFournisseur'); // Cle array returned by the method load_state_board for each line $keys=array('customers', 'prospects', @@ -184,10 +190,12 @@ if (empty($user->societe_id)) 'members', 'products', 'services', - 'proposals', - 'orders', - 'invoices', - 'Contracts'); + 'proposals', + 'orders', + 'invoices', + 'Contracts', + 'supplier_orders', + 'supplier_invoices'); // Dashboard Icon lines $icons=array('company', 'company', @@ -195,10 +203,12 @@ if (empty($user->societe_id)) 'user', 'product', 'service', - 'propal', - 'order', - 'bill', - 'order'); + 'propal', + 'order', + 'bill', + 'order', + 'order', + 'bill'); // Translation keyword $titres=array("ThirdPartyCustomersStats", "ThirdPartyProspectsStats", @@ -209,7 +219,9 @@ if (empty($user->societe_id)) "CommercialProposalsShort", "CustomersOrders", "BillsCustomers", - "Contracts"); + "Contracts", + "SuppliersOrders", + "SuppliersInvoices"); // Dashboard Link lines $links=array(DOL_URL_ROOT.'/comm/list.php', DOL_URL_ROOT.'/comm/prospect/list.php', @@ -220,7 +232,9 @@ if (empty($user->societe_id)) DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial', DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial', DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy', - DOL_URL_ROOT.'/contrat/list.php'); + DOL_URL_ROOT.'/contrat/list.php', + DOL_URL_ROOT.'/fourn/commande/list.php', + DOL_URL_ROOT.'/fourn/facture/list.php'); // Translation lang files $langfile=array("companies", "prospects",