From c63ee8ceb53b4b5188a661102b3a97b3312dc0d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Mar 2016 16:08:51 +0100 Subject: [PATCH] Debug module supplier proposal --- htdocs/comm/propal/class/propal.class.php | 2 +- .../mod_supplier_proposal_marbre.php | 2 +- htdocs/index.php | 34 +++++++++--- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 53 ++++++++++++++++--- 5 files changed, 74 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7905af12030..6d8eb238860 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2565,7 +2565,7 @@ class Propal extends CommonObject if ($mode == 'signed') { $delay_warning=$conf->propal->facturation->warning_delay; $statut = self::STATUS_SIGNED; - $label = $langs->trans("PropalsToBill"); + $label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered } $response = new WorkboardResponse(); diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 9d07dd19514..07d027a68dd 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplie class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' - var $prefix='DF'; + var $prefix='RQ'; // RQ = Request for quotation var $error=''; var $nom = "Marbre"; diff --git a/htdocs/index.php b/htdocs/index.php index 9f186ec1bf7..a98c203fb15 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -170,6 +170,7 @@ if (empty($user->societe_id)) ! empty($conf->contrat->enabled) && $user->rights->contrat->activer, ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), + ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, ! empty($conf->projet->enabled) && $user->rights->projet->lire ); @@ -188,6 +189,7 @@ if (empty($user->societe_id)) 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", + DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php", DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php", DOL_DOCUMENT_ROOT."/projet/class/project.class.php" ); @@ -205,7 +207,8 @@ if (empty($user->societe_id)) 'Contrat', 'CommandeFournisseur', 'FactureFournisseur', - 'ExpenseReport', + 'SupplierProposal', + 'ExpenseReport', 'Project' ); // Cle array returned by the method load_state_board for each line @@ -222,7 +225,8 @@ if (empty($user->societe_id)) 'Contracts', 'supplier_orders', 'supplier_invoices', - 'expensereports', + 'askprice', + 'expensereports', 'projects' ); // Dashboard Icon lines @@ -239,6 +243,7 @@ if (empty($user->societe_id)) 'order', 'order', 'bill', + 'propal', 'trip', 'project' ); @@ -255,7 +260,8 @@ if (empty($user->societe_id)) "BillsCustomers", "Contracts", "SuppliersOrders", - "SuppliersInvoices", + "SuppliersInvoices", + "SupplierProposalShort", "ExpenseReports", "Projects" ); @@ -273,7 +279,8 @@ if (empty($user->societe_id)) DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy', DOL_URL_ROOT.'/contrat/list.php', DOL_URL_ROOT.'/fourn/commande/list.php', - DOL_URL_ROOT.'/fourn/facture/list.php', + DOL_URL_ROOT.'/fourn/facture/list.php', + DOL_URL_ROOT.'/supplier_proposal/list.php', DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm', DOL_URL_ROOT.'/projet/list.php?mainmenu=project' ); @@ -287,7 +294,8 @@ if (empty($user->societe_id)) "produts", "propal", "orders", - "bills", + "bills", + "supplier_proposal", "contracts", "trips", "projects" @@ -387,9 +395,19 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board=new Propal($db); - $dashboardlines[] = $board->load_board($user,"opened"); - // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[] = $board->load_board($user,"signed"); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); +} + +// Number of commercial proposals opened (expired) +if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +{ + include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; + $board=new SupplierProposal($db); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of customer orders a deal diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a66c849bf3a..022d2aaf572 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1076,7 +1076,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', 's.fournisseur = 1', 1); + print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty'); print ''; } print '' . "\n"; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b5319210fc7..18ab21ad9af 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -139,6 +139,29 @@ class SupplierProposal extends CommonObject var $multicurrency_total_tva; var $multicurrency_total_ttc; + /** + * Draft status + */ + const STATUS_DRAFT = 0; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; + /** + * Signed quote + */ + const STATUS_SIGNED = 2; + /** + * Not signed quote + */ + const STATUS_NOTSIGNED = 3; + /** + * Billed quote + */ + const STATUS_BILLED = 4; + + + /** * Constructor * @@ -2087,7 +2110,7 @@ class SupplierProposal extends CommonObject */ function load_board($user,$mode) { - global $conf, $user; + global $conf, $user, $langs; $now=dol_now(); @@ -2110,29 +2133,43 @@ class SupplierProposal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($mode == 'opened') $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - if ($mode == 'signed') $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + if ($mode == 'opened') { + $delay_warning=$conf->supplier_proposal->cloture->warning_delay; + $statut = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); + } + if ($mode == 'signed') { + $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + $statut = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + } + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning/60/60/24; + $response->label = $label; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->img = img_object($langs->trans("SupplierProposals"),"propal"); + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { - $this->nbtodo++; + $response->nbtodo++; if ($mode == 'opened') { $datelimit = $this->db->jdate($obj->datefin); if ($datelimit < ($now - $delay_warning)) { - $this->nbtodolate++; + $response->nbtodolate++; } } // TODO Definir regle des propales a facturer en retard // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; } - return 1; + return $response; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } @@ -2257,7 +2294,7 @@ class SupplierProposal extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } }