*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,33 +22,33 @@
*/
/**
- * \file htdocs/comm/index.php
- * \ingroup commercial
- * \brief Home page of commercial area
+ * \file htdocs/comm/index.php
+ * \ingroup commercial
+ * \brief Home page of commercial area
*/
require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
-require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
-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->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
-if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
if (!$user->rights->societe->lire) accessforbidden();
-$hookmanager = new HookManager($db);
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
+require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('commercialindex'));
// Load translation files required by the page
-$langs->loadLangs(array("commercial", "propal"));
+$langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal"));
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'aZ09');
$bid = GETPOST('bid', 'int');
// Securite acces client
@@ -58,7 +58,7 @@ if (isset($user->socid) && $user->socid > 0) {
$socid = $user->socid;
}
-$max = 3;
+$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
$now = dol_now();
/*
@@ -84,7 +84,8 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
print '';
-if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
+// This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) {
// Search proposal
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$listofsearchfields['search_proposal'] = array('text'=>'Proposal');
@@ -136,19 +137,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless
* Draft customer proposals
*/
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
- $langs->load("propal");
-
- $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
- $sql .= ", s.code_client";
- $sql .= ", s.email";
- $sql .= ", s.entity";
- $sql .= ", s.code_compta";
+ $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE p.fk_statut = 0";
+ $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_soc = s.rowid";
- $sql .= " AND p.entity IN (".getEntity('propal').")";
+ $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
@@ -157,7 +153,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$total = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num);
+ startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
if ($num > 0) {
$i = 0;
@@ -185,16 +181,17 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
print '
';
print '| '.$propalstatic->getNomUrl(1).' | ';
print ''.$companystatic->getNomUrl(1, 'customer', 16).' | ';
- print ''.price($obj->total_ht).' | ';
+ print ''.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).' | ';
print '
';
$i++;
- $total += $obj->total_ht;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -206,28 +203,23 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
* Draft supplier proposals
*/
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
- $langs->load("supplier_proposal");
-
- $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
- $sql .= ", s.code_client";
- $sql .= ", s.code_fournisseur";
- $sql .= ", s.entity";
- $sql .= ", s.email";
+ $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE p.fk_statut = 0";
+ $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")";
+ $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
$sql .= " AND p.fk_soc = s.rowid";
- $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND s.rowid = ".$socid;
+ if ($socid) $sql .= " AND s.rowid = ".$socid;
$resql = $db->query($sql);
if ($resql) {
$total = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num);
+ startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num);
if ($num > 0) {
$i = 0;
@@ -251,18 +243,19 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$companystatic->email = $obj->email;
print '';
- print '| '.$supplierproposalstatic->getNomUrl(1).' | ';
+ print ''.$supplierproposalstatic->getNomUrl(1).' | ';
print ''.$companystatic->getNomUrl(1, 'supplier', 16).' | ';
- print ''.price($obj->total_ht).' | ';
+ print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).' | ';
print '
';
$i++;
- $total += $obj->total_ht;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -274,28 +267,23 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
* Draft customer orders
*/
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
- $langs->load("orders");
-
- $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
- $sql .= ", s.code_client";
- $sql .= ", s.email";
- $sql .= ", s.entity";
- $sql .= ", s.code_compta";
+ $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc";
+ $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE c.fk_soc = s.rowid";
- $sql .= " AND c.fk_statut = 0";
- $sql .= " AND c.entity IN (".getEntity('commande').")";
+ $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
+ $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
+ $sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+ if ($socid) $sql .= " AND c.fk_soc = ".$socid;
$resql = $db->query($sql);
if ($resql) {
$total = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- startSimpleTable("DraftOrders", "commande/list.php", "search_status=0", 2, $num);
+ startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num);
if ($num > 0) {
$i = 0;
@@ -326,12 +314,13 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
print '';
$i++;
- $total += $obj->total_ttc;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -343,28 +332,23 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
* Draft suppliers orders
*/
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->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 .= ", s.entity";
- $sql .= ", s.email";
+ $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc";
+ $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email";
$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').")";
+ $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")";
+ $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
+ $sql .= " AND cf.fk_soc = s.rowid";
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;
+ if ($socid) $sql .= " AND cf.fk_soc = ".$socid;
$resql = $db->query($sql);
if ($resql) {
$total = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num);
+ startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num);
if ($num > 0) {
$i = 0;
@@ -395,39 +379,33 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
print '';
$i++;
- $total += $obj->total_ttc;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
}
}
-print '';
-
-$max = 3;
+print '
';
+print '
';
/*
* Last modified customers or prospects
*/
if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
- $langs->load("boxes");
-
- $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
- $sql .= ", s.code_client";
- $sql .= ", s.code_compta";
- $sql .= ", s.entity";
- $sql .= ", s.email";
+ $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas, s.code_client, s.code_compta, s.entity, s.email";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE s.client IN (1, 2, 3)";
- $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+ $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
+ $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND s.rowid = $socid";
+ if ($socid) $sql .= " AND s.rowid = $socid";
$sql .= " ORDER BY s.tms DESC";
$sql .= $db->plimit($max, 0);
@@ -474,6 +452,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
addSummaryTableLine(3, $num);
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -485,18 +464,13 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
* Last suppliers
*/
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) {
- $langs->load("boxes");
-
- $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm";
- $sql .= ", s.code_fournisseur";
- $sql .= ", s.entity";
- $sql .= ", s.email";
+ $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm, s.code_fournisseur, s.entity, s.email";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE s.fournisseur = 1";
- $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+ $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
+ $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND s.rowid = ".$socid;
+ if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY s.datec DESC";
$sql .= $db->plimit($max, 0);
@@ -529,6 +503,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
addSummaryTableLine(2, $num);
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -548,7 +523,7 @@ if ($user->rights->agenda->myactions->read) {
* Actions to do
*/
if ($user->rights->agenda->myactions->read) {
- show_array_actions_to_do(10);
+ show_array_actions_to_do($max);
}
@@ -556,33 +531,29 @@ if ($user->rights->agenda->myactions->read) {
* Latest contracts
*/
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
- $langs->load("contracts");
+ $staticcontrat = new Contrat($db);
- $sql = "SELECT s.nom as name, s.rowid, s.canvas, ";
- $sql .= ", s.code_client";
- $sql .= ", s.entity";
- $sql .= ", s.email";
+ $sql = "SELECT s.nom as name, s.rowid, s.canvas, s.code_client, s.entity, s.email";
$sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE c.fk_soc = s.rowid";
- $sql .= " AND c.entity IN (".getEntity('contract').")";
+ $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
+ $sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.fk_product = p.rowid";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY c.tms DESC";
- $sql .= $db->plimit(5, 0);
+ $sql .= $db->plimit($max + 1, 0);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
- startSimpleTable($langs->trans("LastContracts", 5), "", "", 2);
+ startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
if ($num > 0) {
$i = 0;
- $staticcontrat = new Contrat($db);
while ($i < $num) {
$obj = $db->fetch_object($resql);
@@ -607,6 +578,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T
addSummaryTableLine(2, $num);
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -615,38 +587,43 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T
/*
- * Opened proposals
+ * Opened (validated) proposals
*/
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
- $langs->load("propal");
-
- $sql = "SELECT s.nom as name, s.rowid, s.code_client";
- $sql .= ", s.entity";
- $sql .= ", s.email";
- $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."propal as p";
+ $sql = "SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
+ $sql .= ", s.nom as name, s.rowid, s.code_client, s.entity, s.email";
+ $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+ $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE p.fk_soc = s.rowid";
- $sql .= " AND p.entity IN (".getEntity('propal').")";
- $sql .= " AND p.fk_statut = 1";
+ $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
+ $sql .= " AND p.fk_soc = s.rowid";
+ $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY p.rowid DESC";
$resql = $db->query($sql);
if ($resql) {
- $total = 0;
+ $total = $total_ttc = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
if ($num > 0) {
$i = 0;
+ $othernb = 0;
while ($i < $nbofloop) {
$obj = $db->fetch_object($resql);
+ if ($i >= $max) {
+ $othernb += 1;
+ $i++;
+ $total += $obj->total_ht;
+ $total_ttc += $obj->total_ttc;
+ continue;
+ }
+
$propalstatic->id = $obj->propalid;
$propalstatic->ref = $obj->ref;
$propalstatic->ref_client = $obj->ref_client;
@@ -663,24 +640,21 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$companystatic->entity = $obj->entity;
$companystatic->email = $obj->email;
- print '
';
-
- // Ref
- print '';
- print '';
- print '| ';
- print $propalstatic->getNomUrl(1);
- print ' | ';
- print '';
- if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
- print ' | ';
- print '';
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
- print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
- print ' | ';
- print " | ";
+ $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
+
+ print '
';
+
+ print '';
+ print '';
+ print '| '.$propalstatic->getNomUrl(1).' | ';
+ print ''.$warning.' | ';
+ print ''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).' | ';
+ print ' ';
+ print ' ';
+ print ' | ';
print ''.$companystatic->getNomUrl(1, 'customer', 44).' | ';
print ''.dol_print_date($db->jdate($obj->dp), 'day').' | ';
@@ -690,12 +664,22 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
print '
';
$i++;
- $total += $obj->total_ttc;
+ $total += $obj->total_ht;
+ $total_ttc += $obj->total_ttc;
+ }
+
+ if ($othernb) {
+ print '
';
+ print '| ';
+ print ''.$langs->trans("More").'... ('.$othernb.')';
+ print ' | ';
+ print "
\n";
}
}
- addSummaryTableLine(5, $num, $nbofloop, $total, "NoProposal", true);
+ addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "NoProposal", true);
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
@@ -704,38 +688,43 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
/*
- * Opened Order
+ * Opened (validated) order
*/
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
- $langs->load("orders");
-
- $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
- $sql .= ", s.code_client";
- $sql .= ", s.entity";
- $sql .= ", s.email";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."commande as c";
+ $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
+ $sql .= ", s.nom as name, s.rowid, s.code_client, s.entity, s.email";
+ $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
+ $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE c.fk_soc = s.rowid";
- $sql .= " AND c.entity IN (".getEntity('commande').")";
- $sql .= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")";
+ $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
+ $sql .= " AND c.fk_soc = s.rowid";
+ $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY c.rowid DESC";
$resql = $db->query($sql);
if ($resql) {
- $total = 0;
+ $total = $total_ttc = 0;
$num = $db->num_rows($resql);
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- startSimpleTable("OrdersOpened", "commande/list.php", "search_status=1", 4, $num);
+ startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
if ($num > 0) {
$i = 0;
+ $othernb = 0;
while ($i < $nbofloop) {
$obj = $db->fetch_object($resql);
+ if ($i >= $max) {
+ $othernb += 1;
+ $i++;
+ $total += $obj->total_ht;
+ $total_ttc += $obj->total_ttc;
+ continue;
+ }
+
$orderstatic->id = $obj->commandeid;
$orderstatic->ref = $obj->ref;
$orderstatic->ref_client = $obj->ref_client;
@@ -752,45 +741,55 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$companystatic->entity = $obj->entity;
$companystatic->email = $obj->email;
- print '
';
-
- // Ref
- print '';
- print '';
- print '| ';
- print $orderstatic->getNomUrl(1);
- print ' | ';
- print '';
- //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
- print ' | ';
- print '';
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
- print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
- print ' | ';
- print " | ";
+ //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
+
+ print '
';
+
+ print '';
+ print '';
+ print '| '.$orderstatic->getNomUrl(1).' | ';
+ print ' | ';
+ print ''.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).' | ';
+ print ' ';
+ print ' ';
+ print ' | ';
print ''.$companystatic->getNomUrl(1, 'customer', 44).' | ';
print ''.dol_print_date($db->jdate($obj->dp), 'day').' | ';
print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).' | ';
print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).' | ';
- print '
'."\n";
+
+ print '';
$i++;
- $total += $obj->total_ttc;
+ $total += $obj->total_ht;
+ $total_ttc += $obj->total_ttc;
+ }
+
+ if ($othernb) {
+ print '
';
+ print '| ';
+ print ''.$langs->trans("More").'... ('.$othernb.')';
+ print ' | ';
+ print "
\n";
}
}
- addSummaryTableLine(5, $num, $nbofloop, $num, $total, "None", true);
+ addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "None", true);
finishSimpleTable(true);
+
$db->free($resql);
} else {
dol_print_error($db);
}
}
-print '
';
+print '
';
+print '';
+print '';
$parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php
index da24f7bcb4f..29b06819e9e 100644
--- a/htdocs/comm/mailing/advtargetemailing.php
+++ b/htdocs/comm/mailing/advtargetemailing.php
@@ -46,8 +46,8 @@ if (!$user->rights->mailing->lire || $user->socid > 0)
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'alpha');
-$sortorder = GETPOST('sortorder', 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index ccccc93da4f..13037b58769 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -41,7 +41,7 @@ $langs->load("mails");
if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) accessforbidden();
$id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int'));
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$urlfrom = GETPOST('urlfrom');
@@ -462,14 +462,14 @@ if (empty($reshook))
{
$mesgs = array();
- $object->email_from = trim($_POST["from"]);
- $object->email_replyto = trim($_POST["replyto"]);
- $object->email_errorsto = trim($_POST["errorsto"]);
- $object->titre = trim($_POST["titre"]);
- $object->sujet = trim($_POST["sujet"]);
- $object->body = trim($_POST["bodyemail"]);
- $object->bgcolor = trim($_POST["bgcolor"]);
- $object->bgimage = trim($_POST["bgimage"]);
+ $object->email_from = GETPOST("from");
+ $object->email_replyto = GETPOST("replyto");
+ $object->email_errorsto = GETPOST("errorsto");
+ $object->titre = GETPOST("titre");
+ $object->sujet = GETPOST("sujet");
+ $object->body = GETPOST("bodyemail", 'restricthtml');
+ $object->bgcolor = GETPOST("bgcolor");
+ $object->bgimage = GETPOST("bgimage");
if (!$object->titre) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
@@ -563,10 +563,10 @@ if (empty($reshook))
{
$mesgs = array();
- $object->sujet = trim($_POST["sujet"]);
- $object->body = trim($_POST["bodyemail"]);
- $object->bgcolor = trim($_POST["bgcolor"]);
- $object->bgimage = trim($_POST["bgimage"]);
+ $object->sujet = GETPOST("sujet");
+ $object->body = GETPOST("bodyemail", 'restricthtml');
+ $object->bgcolor = GETPOST("bgcolor");
+ $object->bgimage = GETPOST("bgimage");
if (!$object->sujet) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic"));
@@ -738,7 +738,7 @@ if ($action == 'create')
print '';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%');
+ $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtml'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%');
$doleditor->Create();
print '
';
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 27e0c2e5b0c..813a195007b 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -41,8 +41,8 @@ if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden();
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'alpha');
-$sortorder = GETPOST('sortorder', 'alpha');
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php
index 983ad374980..f82ebec9d6f 100644
--- a/htdocs/comm/mailing/class/advtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/advtargetemailing.class.php
@@ -567,7 +567,7 @@ class AdvanceTargetingMailing extends CommonObject
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
- $sqlwhere[] = " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+ $sqlwhere[] = " (te.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key])."')";
}
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
@@ -587,7 +587,7 @@ class AdvanceTargetingMailing extends CommonObject
if (is_array($arrayquery['options_'.$key])) {
$sqlwhere[] = " (te.".$key." IN ('".implode("','", $arrayquery['options_'.$key])."'))";
} elseif (!empty($arrayquery['options_'.$key])) {
- $sqlwhere[] = " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+ $sqlwhere[] = " (te.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key])."')";
}
}
}
@@ -664,13 +664,13 @@ class AdvanceTargetingMailing extends CommonObject
$sqlwhere[] = $this->transformToSQL('t.firstname', $arrayquery['contact_firstname']);
}
if (!empty($arrayquery['contact_country']) && count($arrayquery['contact_country'])) {
- $sqlwhere[] = " (t.fk_pays IN (".$this->db->escape(implode(',', $arrayquery['contact_country']))."))";
+ $sqlwhere[] = " (t.fk_pays IN (".$this->db->sanitize($this->db->escape(implode(',', $arrayquery['contact_country'])))."))";
}
if (!empty($arrayquery['contact_status']) && count($arrayquery['contact_status']) > 0) {
- $sqlwhere[] = " (t.statut IN (".$this->db->escape(implode(',', $arrayquery['contact_status']))."))";
+ $sqlwhere[] = " (t.statut IN (".$this->db->sanitize($this->db->escape(implode(',', $arrayquery['contact_status'])))."))";
}
if (!empty($arrayquery['contact_civility']) && count($arrayquery['contact_civility']) > 0) {
- $sqlwhere[] = " (t.civility IN ('".$this->db->escape(implode("','", $arrayquery['contact_civility']))."'))";
+ $sqlwhere[] = " (t.civility IN ('".$this->db->sanitize($this->db->escape(implode("','", $arrayquery['contact_civility'])))."'))";
}
if ($arrayquery['contact_no_email'] != '') {
$tmpwhere = '';
@@ -708,7 +708,7 @@ class AdvanceTargetingMailing extends CommonObject
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key.'_cnct'])) {
- $sqlwhere[] = " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')";
+ $sqlwhere[] = " (te.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key.'_cnct'])."')";
}
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
@@ -732,7 +732,7 @@ class AdvanceTargetingMailing extends CommonObject
if (is_array($arrayquery['options_'.$key.'_cnct'])) {
$sqlwhere[] = " (te.".$key." IN ('".implode("','", $arrayquery['options_'.$key.'_cnct'])."'))";
} elseif (!empty($arrayquery['options_'.$key.'_cnct'])) {
- $sqlwhere[] = " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')";
+ $sqlwhere[] = " (te.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key.'_cnct'])."')";
}
}
}
@@ -810,7 +810,7 @@ class AdvanceTargetingMailing extends CommonObject
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
- $sqlwhere[] = " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+ $sqlwhere[] = " (tse.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key])."')";
}
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
@@ -830,7 +830,7 @@ class AdvanceTargetingMailing extends CommonObject
if (is_array($arrayquery['options_'.$key])) {
$sqlwhere[] = " (tse.".$key." IN ('".implode("','", $arrayquery['options_'.$key])."'))";
} elseif (!empty($arrayquery['options_'.$key])) {
- $sqlwhere[] = " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
+ $sqlwhere[] = " (tse.".$key." LIKE '".$this->db->escape($arrayquery['options_'.$key])."')";
}
}
}
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 5c53f6715a2..f42b82718e6 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -68,7 +68,7 @@ $error = 0;
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
@@ -355,8 +355,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid', 'int');
$object->model_pdf = GETPOST('model');
$object->author = $user->id; // deprecated
- $object->note_private = GETPOST('note_private', 'none');
- $object->note_public = GETPOST('note_public', 'none');
+ $object->note_private = GETPOST('note_private', 'restricthtml');
+ $object->note_public = GETPOST('note_public', 'restricthtml');
$object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@@ -383,8 +383,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid', 'int');
$object->model_pdf = GETPOST('model');
$object->author = $user->id; // deprecated
- $object->note_private = GETPOST('note_private', 'none');
- $object->note_public = GETPOST('note_public', 'none');
+ $object->note_private = GETPOST('note_private', 'restricthtml');
+ $object->note_public = GETPOST('note_public', 'restricthtml');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@@ -627,7 +627,7 @@ if (empty($reshook))
{
$db->begin();
- $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'none'));
+ $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'restricthtml'));
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@@ -792,9 +792,9 @@ if (empty($reshook))
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
- $product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'none') : '');
- $price_ht = GETPOST('price_ht');
- $price_ht_devise = GETPOST('multicurrency_price_ht');
+ $product_desc = (GETPOSTISSET('dp_desc') ?GETPOST('dp_desc', 'restricthtml') : '');
+ $price_ht = price2num(GETPOST('price_ht'));
+ $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
@@ -1152,7 +1152,7 @@ if (empty($reshook))
$info_bits |= 0x01;
// Clean parameters
- $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none'));
+ $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
// Define vat_rate
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
@@ -1316,7 +1316,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
- $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
+ $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
if ($ret < 0) $error++;
if (!$error)
{
@@ -1508,7 +1508,7 @@ if ($action == 'create')
}
} else {
print '';
- print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
+ print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500');
// reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
{
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index 8efc4aa5c19..0f157396f35 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -190,7 +190,7 @@ class Proposals extends DolibarrApi
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
- $sql .= $db->order($sortfield, $sortorder);
+ $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
@@ -198,21 +198,21 @@ class Proposals extends DolibarrApi
}
$offset = $limit * $page;
- $sql .= $db->plimit($limit + 1, $offset);
+ $sql .= $this->db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
- $result = $db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
- $num = $db->num_rows($result);
+ $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
- $obj = $db->fetch_object($result);
- $proposal_static = new Propal($db);
+ $obj = $this->db->fetch_object($result);
+ $proposal_static = new Propal($this->db);
if ($proposal_static->fetch($obj->rowid)) {
// Add external contacts ids
$proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1);
@@ -221,7 +221,7 @@ class Proposals extends DolibarrApi
$i++;
}
} else {
- throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
+ throw new RestException(503, 'Error when retrieve propal list : '.$this->db->lasterror());
}
if (!count($obj_ret)) {
throw new RestException(404, 'No proposal found');
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index d1936d9d17e..7e34ac6fc3c 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -41,12 +41,15 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
/**
* Class to manage proposals
*/
class Propal extends CommonObject
{
+ use CommonIncoterm;
+
/**
* @var string ID to identify managed object
*/
@@ -1058,7 +1061,7 @@ class Propal extends CommonObject
$sql .= ", '".$this->db->idate($this->date)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '(PROV)'";
- $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "NULL");
+ $sql .= ", ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL");
$sql .= ", '".$this->db->escape($this->note_private)."'";
$sql .= ", '".$this->db->escape($this->note_public)."'";
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index c2f60516f1c..16be5930e89 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -38,7 +38,7 @@ $langs->loadLangs(array('facture', 'orders', 'sendings', 'companies'));
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$lineid = GETPOST('lineid', 'int');
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 9e138c52cbe..692f561867a 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2019 Nicolas ZABOURI
+/* Copyright (C) 2003-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2019 Nicolas ZABOURI
+ * Copyright (C) 2020 Tobias Sekan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,22 +20,12 @@
*/
/**
- * \file htdocs/comm/propal/index.php
- * \ingroup propal
- * \brief Home page of proposal area
+ * \file htdocs/comm/propal/index.php
+ * \ingroup propal
+ * \brief Home page of proposal area
*/
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
-
-$hookmanager = new HookManager($db);
-
-// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
-$hookmanager->initHooks(array('proposalindex'));
-
-// Load translation files required by the page
-$langs->loadLangs(array('propal', 'companies'));
// Security check
$socid = GETPOST('socid', 'int');
@@ -43,13 +34,24 @@ if (isset($user->socid) && $user->socid > 0)
$action = '';
$socid = $user->socid;
}
-$result = restrictedArea($user, 'propal');
+restrictedArea($user, 'propal');
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager = new HookManager($db);
+$hookmanager->initHooks(array('proposalindex'));
+
+// Load translation files required by the page
+$langs->loadLangs(array('propal', 'companies'));
+
+$now = dol_now();
+$max = 5;
/*
* View
*/
-$now = dol_now();
$propalstatic = new Propal($db);
$companystatic = new Societe($db);
$form = new Form($db);
@@ -60,192 +62,218 @@ llxHeader("", $langs->trans("ProspectionArea"), $help_url);
print load_fiche_titre($langs->trans("ProspectionArea"), '', 'propal');
-//print '';
-//print '';
-print '';
+print ' ';
+print ' ';
-
-if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
+// This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))
{
- print ' \n";
-}
+ print ' ';
+ print ' ';
+}
/*
* Statistics
*/
+$listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED);
$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql .= " WHERE p.fk_soc = s.rowid";
-$sql .= " AND p.entity IN (".getEntity('propal').")";
+$sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
+$sql .= " AND p.fk_soc = s.rowid";
if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-$sql .= " AND p.fk_statut IN (0,1,2,3,4)";
+$sql .= " AND p.fk_statut IN (".implode(" ,", $listofstatus).")";
$sql .= " GROUP BY p.fk_statut";
$resql = $db->query($sql);
if ($resql)
{
- $num = $db->num_rows($resql);
- $i = 0;
+ $num = $db->num_rows($resql);
+ $i = 0;
+ $total = 0;
+ $totalinprocess = 0;
+ $dataseries = array();
+ $colorseries = array();
+ $vals = array();
- $total = 0;
- $totalinprocess = 0;
- $dataseries = array();
- $colorseries = array();
- $vals = array();
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj)
+ {
+ $vals[$obj->status] = $obj->nb;
+ $totalinprocess += $obj->nb;
- // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- if ($obj)
- {
- $vals[$obj->status] = $obj->nb;
- $totalinprocess += $obj->nb;
+ $total += $obj->nb;
+ }
+ $i++;
+ }
+ $db->free($resql);
- $total += $obj->nb;
- }
- $i++;
- }
- $db->free($resql);
+ include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
- include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
+ print ' ';
+ print ' ';
- print '';
- print ' ';
- print '| '.$langs->trans("Statistics").' - '.$langs->trans("Proposals").' | '."\n";
- $listofstatus = array(0, 1, 2, 3, 4);
- foreach ($listofstatus as $status)
- {
- $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
- if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
- if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
- if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4;
- if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9;
- if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6;
+ print '';
+ print '| '.$langs->trans("Statistics").' - '.$langs->trans("Proposals").' | ';
+ print ' ';
- if (empty($conf->use_javascript_ajax))
- {
- print '';
- print '| '.$propalstatic->LibStatut($status, 0).' | ';
- print ''.(isset($vals[$status]) ? $vals[$status] : 0).' | ';
- print " \n";
- }
- }
- if ($conf->use_javascript_ajax)
- {
- print '| ';
+ foreach ($listofstatus as $status) {
+ $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
+ if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
+ if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
+ if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4;
+ if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9;
+ if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6;
- include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
- $dolgraph = new DolGraph();
- $dolgraph->SetData($dataseries);
- $dolgraph->SetDataColor(array_values($colorseries));
- $dolgraph->setShowLegend(2);
- $dolgraph->setShowPercent(1);
- $dolgraph->SetType(array('pie'));
- $dolgraph->setHeight('200');
- $dolgraph->draw('idgraphthirdparties');
- print $dolgraph->show($total ? 0 : 1);
+ if (empty($conf->use_javascript_ajax)) {
+ print ' | ';
+ print '| '.$propalstatic->LibStatut($status, 0).' | ';
+ print ''.(isset($vals[$status]) ? $vals[$status] : 0).' | ';
+ print " \n";
+ }
+ }
- print '';
- }
- //if ($totalinprocess != $total)
- //print '| '.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").') | '.$totalinprocess.' | ';
- print '| '.$langs->trans("Total").' | '.$total.' | ';
- print " ";
+ if ($conf->use_javascript_ajax) {
+ print '';
+ print '| ';
+
+ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+ $dolgraph = new DolGraph();
+ $dolgraph->SetData($dataseries);
+ $dolgraph->SetDataColor(array_values($colorseries));
+ $dolgraph->setShowLegend(2);
+ $dolgraph->setShowPercent(1);
+ $dolgraph->SetType(array('pie'));
+ $dolgraph->setHeight('200');
+ $dolgraph->draw('idgraphthirdparties');
+ print $dolgraph->show($total ? 0 : 1);
+
+ print ' | ';
+ print ' ';
+ }
+
+ //if ($totalinprocess != $total)
+ //{
+ // print '';
+ // print '| '.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").') | ';
+ // print ''.$totalinprocess.' | ';
+ // print ' ';
+ //}
+
+ print '';
+ print '| '.$langs->trans("Total").' | ';
+ print ''.$total.' | ';
+ print ' ';
+
+ print ' ';
+ print ' ';
+ print ' ';
} else {
- dol_print_error($db);
+ dol_print_error($db);
}
/*
* Draft proposals
*/
-if (!empty($conf->propal->enabled))
-{
- $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
- $sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
+if (!empty($conf->propal->enabled)) {
+ $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
+ $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE c.fk_soc = s.rowid";
- $sql .= " AND c.entity IN (".getEntity('propal').")";
- $sql .= " AND c.fk_statut = 0";
- if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+ $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
+ $sql .= " AND p.fk_soc = s.rowid";
+ $sql .= " AND p.fk_statut =".Propal::STATUS_DRAFT;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid) $sql .= " AND p.fk_soc = ".$socid;
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
- if ($num)
- {
- print ' ';
- print ' ';
- print '';
- $langs->load("propal");
- print '| '.$langs->trans("DraftPropals").' '.$num.' | ';
+ $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
+ startSimpleTable("DraftPropals", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
+ if ($num) {
+ $total = 0;
$i = 0;
- $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- while ($i < $nbofloop)
- {
+
+ while ($i < $nbofloop) {
$obj = $db->fetch_object($resql);
- print '';
$propalstatic->id = $obj->rowid;
$propalstatic->ref = $obj->ref;
- print '| '.$propalstatic->getNomUrl(1).' | ';
+ $propalstatic->ref_client = $obj->ref_client;
+ $propalstatic->total_ht = $obj->total_ht;
+ $propalstatic->total_tva = $obj->total_tva;
+ $propalstatic->total_ttc = $obj->total_ttc;
$companystatic->id = $obj->socid;
- $companystatic->name = $obj->socname;
+ $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', 24).' | ';
+ $companystatic->entity = $obj->entity;
+ $companystatic->email = $obj->email;
+ $companystatic->code_compta = $obj->code_compta;
+ print ' ';
+ print '| '.$propalstatic->getNomUrl(1).' | ';
+ print ''.$companystatic->getNomUrl(1, 'customer', 16).' | ';
+ print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).' | ';
print ' ';
+
$i++;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
- if ($num > $nbofloop)
- {
- print '| '.$langs->trans("XMoreLines", ($num - $nbofloop))." | ";
- } elseif ($total > 0)
- {
- print '| '.$langs->trans("Total").' | '.price($total)." | ";
- }
- print " ";
- print " ";
}
+
+ addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
+ finishSimpleTable(true);
+ $db->free($resql);
+ } else {
+ dol_print_error($db);
}
}
+print ' ';
-//print ' | ';
-print '';
-
-
-$max = 5;
+print ' ';
+print ' ';
/*
* Last modified proposals
*/
-$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
-$sql .= " date_cloture as datec";
+$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec";
+$sql .= ", s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql .= " WHERE c.fk_soc = s.rowid";
-$sql .= " AND c.entity IN (".getEntity('propal').")";
+$sql .= " WHERE c.entity IN (".getEntity($propalstatic->element).")";
+$sql .= " AND c.fk_soc = s.rowid";
//$sql.= " AND c.fk_statut > 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@@ -253,150 +281,126 @@ $sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
-if ($resql)
-{
- print ' ';
- print ' ';
- print '';
- print '| '.$langs->trans("LastModifiedProposals", $max).' | ';
-
+if ($resql) {
$num = $db->num_rows($resql);
- if ($num)
- {
- $i = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ startSimpleTable($langs->trans("LastModifiedProposals", $max), "", "", 3);
- print '';
- print '';
+ if ($num) {
+ $i = 0;
+ while ($i < $num) {
+ $obj = $db->fetch_object($resql);
$propalstatic->id = $obj->rowid;
$propalstatic->ref = $obj->ref;
- print '';
- print '| ';
- print $propalstatic->getNomUrl(1);
- print ' | ';
-
- print '';
- print ' ';
- print ' | ';
-
- print '';
- $filename = dol_sanitizeFileName($obj->ref);
- $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
- $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
- print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
- print ' | ';
-
- print ' | ';
-
$companystatic->id = $obj->socid;
$companystatic->name = $obj->socname;
$companystatic->client = $obj->client;
$companystatic->canvas = $obj->canvas;
- print ''.$companystatic->getNomUrl(1, 'customer').' | ';
- print ''.dol_print_date($db->jdate($obj->datec), 'day').' | ';
+ $filename = dol_sanitizeFileName($obj->ref);
+ $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+ $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
- print ''.$propalstatic->LibStatut($obj->fk_statut, 3).' | ';
+ print ' ';
+
+ print '';
+ print '';
+ print '';
+ print '| '.$propalstatic->getNomUrl(1).' | ';
+ print ' | ';
+ print ''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).' | ';
print ' ';
+ print ' ';
+ print ' | ';
+
+ print ''.$companystatic->getNomUrl(1, 'customer').' | ';
+ print ''.dol_print_date($db->jdate($obj->datec), 'day').' | ';
+ print ''.$propalstatic->LibStatut($obj->fk_statut, 3).' | ';
+
+ print ' ';
+
$i++;
}
}
- print " ";
- print " ";
-} else dol_print_error($db);
+
+ finishSimpleTable(true);
+ $db->free($resql);
+} else {
+ dol_print_error($db);
+}
/*
- * Open proposals
+ * Open (validated) proposals
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
-{
- $langs->load("propal");
-
- $now = dol_now();
-
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_soc = s.rowid";
- $sql .= " AND p.entity IN (".getEntity('propal').")";
- $sql .= " AND p.fk_statut = 1";
+ $sql .= " AND p.entity IN (".getEntity($propalstatic->element).")";
+ $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY p.rowid DESC";
- $result = $db->query($sql);
- if ($result)
- {
+ $resql = $db->query($sql);
+ if ($resql) {
$total = 0;
- $num = $db->num_rows($result);
- $i = 0;
- if ($num > 0)
- {
- print ' ';
- print ' ';
- print '| '.$langs->trans("ProposalsOpened").' '.$num.' | ';
+ $num = $db->num_rows($resql);
+ $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
+ startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=".Propal::STATUS_VALIDATED, 4, $num);
- $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
- while ($i < $nbofloop)
- {
- $obj = $db->fetch_object($result);
-
- print '';
-
- // Ref
- print '';
+ if ($num > 0) {
+ $i = 0;
+ while ($i < $nbofloop) {
+ $obj = $db->fetch_object($resql);
$propalstatic->id = $obj->propalid;
$propalstatic->ref = $obj->ref;
- print '';
- print '| ';
- print $propalstatic->getNomUrl(1);
- print ' | ';
- print '';
- if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
- print ' | ';
- print '';
- $filename = dol_sanitizeFileName($obj->ref);
- $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
- $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
- print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
- print ' | ';
-
- print " | ";
-
$companystatic->id = $obj->socid;
$companystatic->name = $obj->socname;
$companystatic->client = $obj->client;
$companystatic->canvas = $obj->canvas;
- print ''.$companystatic->getNomUrl(1, 'customer', 44).' | '."\n";
- print ''.dol_print_date($db->jdate($obj->dp), 'day').' | '."\n";
+ $filename = dol_sanitizeFileName($obj->ref);
+ $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+ $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
- print ''.price($obj->total_ttc).' | ';
+ $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
+
+ print ' ';
+
+ // Ref
+ print '';
+ print '';
+ print '';
+ print '| '.$propalstatic->getNomUrl(1).' | ';
+ print ''.$warning.' | ';
+ print ''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).' | ';
+ print ' ';
+ print ' ';
+ print ' | ';
+
+ print ''.$companystatic->getNomUrl(1, 'customer', 44).' | ';
+ print ''.dol_print_date($db->jdate($obj->dp), 'day').' | ';
+ print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).' | ';
+ print ''.$propalstatic->LibStatut($obj->fk_statut, 3).' | ';
+
+ print ' ';
- print ''.$propalstatic->LibStatut($obj->fk_statut, 3).' | '."\n";
- print ''."\n";
$i++;
- $total += $obj->total_ttc;
+ $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
}
- if ($num > $nbofloop)
- {
- print '| '.$langs->trans("XMoreLines", ($num - $nbofloop))." | ";
- } elseif ($total > 0)
- {
- print '| '.$langs->trans("Total")." | ".price($total)." | | ";
- }
- print " ";
- print " ";
}
+
+ addSummaryTableLine(5, $num, $nbofloop, $total, "None", true);
+ finishSimpleTable(true);
+ $db->free($resql);
} else {
dol_print_error($db);
}
@@ -405,6 +409,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
/*
* Proposals to process
*/
+
/*
if (! empty($conf->propal->enabled))
{
@@ -479,7 +484,9 @@ if (! empty($conf->propal->enabled))
/*
* Proposal that are in a shipping process
*/
-/*if (! empty($conf->propal->enabled))
+
+/*
+if (! empty($conf->propal->enabled))
{
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
@@ -548,8 +555,9 @@ if (! empty($conf->propal->enabled))
}
*/
-//print ' | ';
-print '';
+print '';
+print '';
+print '';
$parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardPropals', $parameters, $object); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 7bce96633fc..dde38d98489 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -50,7 +50,7 @@ $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'pro
$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
@@ -333,13 +333,13 @@ if (!$user->rights->societe->client->voir && !$socid) //restriction
if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
-if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
-if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
+if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
+if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
if ($search_project) $sql .= natural_search('pr.title', $search_project);
-if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
+if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')';
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_login) $sql .= natural_search("u.login", $search_login);
@@ -361,7 +361,7 @@ if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape(
if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
if ($search_status != '' && $search_status != '-1')
{
- $sql .= ' AND p.fk_statut IN ('.$db->escape($search_status).')';
+ $sql .= ' AND p.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
}
if ($search_date_start) $sql .= " AND p.datep >= '".$db->idate($search_date_start)."'";
if ($search_date_end) $sql .= " AND p.datep <= '".$db->idate($search_date_end)."'";
@@ -480,11 +480,9 @@ if ($resql)
if (in_array($massaction, array('presend', 'predelete', 'closed'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
- $newcardbutton = '';
- if ($user->rights->propal->creer)
- {
- $newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create');
- }
+ $url = DOL_URL_ROOT.'/comm/propal/card.php?action=create';
+ if (!empty($socid)) $url .= '&socid='.$socid;
+ $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer);
// Fields title search
print ' |