';
}
diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php
deleted file mode 100644
index 8ec43d955a4..00000000000
--- a/htdocs/comm/prospect/list.php
+++ /dev/null
@@ -1,613 +0,0 @@
-
- * Copyright (C) 2004-2015 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2011 Philippe Grand
- * Copyright (C) 2013-2015 Florian Henry
- * Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2015 Raphaël Doursenaud
- * Copyright (C) 2015 Marcos García
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/comm/prospect/list.php
- * \ingroup prospect
- * \brief Page to list prospects
- */
-
-require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-
-$langs->load("propal");
-$langs->load("companies");
-
-// Security check
-$socid = GETPOST("socid",'int');
-if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'societe',$socid,'');
-
-$action = GETPOST('action','alpha');
-$socname = GETPOST("socname",'alpha');
-$stcomm = GETPOST("stcomm",'alpha'); // code
-$search_stcomm = GETPOST("search_stcomm",'int');
-$search_nom = GETPOST("search_nom");
-$search_zipcode = GETPOST("search_zipcode");
-$search_town = GETPOST("search_town");
-$search_state = GETPOST("search_state");
-$search_datec = GETPOST("search_datec");
-$search_categ = GETPOST("search_categ",'int');
-$search_status = GETPOST("search_status",'int');
-$catid = GETPOST("catid",'int');
-$search_country = GETPOST("search_country",'int');
-$search_type_thirdparty = GETPOST("search_type_thirdparty",'int');
-
-$sortfield = GETPOST("sortfield",'alpha');
-$sortorder = GETPOST("sortorder",'alpha');
-$page = GETPOST("page",'int');
-if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-if (! $sortorder) $sortorder="ASC";
-if (! $sortfield) $sortfield="s.nom";
-
-$search_level_from = GETPOST("search_level_from","alpha");
-$search_level_to = GETPOST("search_level_to","alpha");
-
-// If both parameters are set, search for everything BETWEEN them
-if ($search_level_from != '' && $search_level_to != '')
-{
- // Ensure that these parameters are numbers
- $search_level_from = (int) $search_level_from;
- $search_level_to = (int) $search_level_to;
-
- // If from is greater than to, reverse orders
- if ($search_level_from > $search_level_to)
- {
- $tmp = $search_level_to;
- $search_level_to = $search_level_from;
- $search_level_from = $tmp;
- }
-
- // Generate the SQL request
- $sortwhere = '(sortorder BETWEEN '.$search_level_from.' AND '.$search_level_to.') AS is_in_range';
-}
-// If only "from" parameter is set, search for everything GREATER THAN it
-else if ($search_level_from != '')
-{
- // Ensure that this parameter is a number
- $search_level_from = (int) $search_level_from;
-
- // Generate the SQL request
- $sortwhere = '(sortorder >= '.$search_level_from.') AS is_in_range';
-}
-// If only "to" parameter is set, search for everything LOWER THAN it
-else if ($search_level_to != '')
-{
- // Ensure that this parameter is a number
- $search_level_to = (int) $search_level_to;
-
- // Generate the SQL request
- $sortwhere = '(sortorder <= '.$search_level_to.') AS is_in_range';
-}
-// If no parameters are set, dont search for anything
-else
-{
- $sortwhere = '0 as is_in_range';
-}
-
-// Select every potentiels, and note each potentiels which fit in search parameters
-dol_syslog('prospects::prospects_prospect_level',LOG_DEBUG);
-$sql = "SELECT code, label, sortorder, ".$sortwhere;
-$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
-$sql.= " WHERE active > 0";
-$sql.= " ORDER BY sortorder";
-
-$resql = $db->query($sql);
-if ($resql)
-{
- $tab_level = array();
- $search_levels = array();
-
- while ($obj = $db->fetch_object($resql))
- {
- // Compute level text
- $level=$langs->trans($obj->code);
- if ($level == $obj->code) $level=$langs->trans($obj->label);
-
- // Put it in the array sorted by sortorder
- $tab_level[$obj->sortorder] = $level;
-
- // If this potentiel fit in parameters, add its code to the $search_levels array
- if ($obj->is_in_range == 1)
- {
- $search_levels[] = '"'.preg_replace('[^A-Za-z0-9_-]', '', $obj->code).'"';
- }
- }
-
- // Implode the $search_levels array so that it can be use in a "IN (...)" where clause.
- // If no paramters was set, $search_levels will be empty
- $search_levels = implode(',', $search_levels);
-}
-else dol_print_error($db);
-
-// Load sale and categ filters
-$search_sale = GETPOST('search_sale','int');
-$search_categ = GETPOST('search_categ','int');
-// If the internal user must only see his prospect, force searching by him
-if (!$user->rights->societe->client->voir && !$socid) $search_sale = $user->id;
-
-// List of available states; we'll need that for each lines (quick changing prospect states) and for search bar (filter by prospect state)
-$sts = array(-1,0,1,2,3);
-
-
-// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-$contextpage='prospectlist';
-$hookmanager->initHooks(array($contextpage));
-$extrafields = new ExtraFields($db);
-
-// fetch optionals attributes and labels
-$extralabels = $extrafields->fetch_name_optionals_label('thirdparty');
-$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
-
-// Do we click on purge search criteria ?
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
-{
- $socname="";
- $stcomm="";
- $search_stcomm="";
- $search_nom="";
- $search_zipcode="";
- $search_town="";
- $search_state="";
- $search_datec="";
- $search_categ="";
- $search_status="";
- $search_country="";
- $search_type_thirdparty="";
- $search_array_options=array();
-}
-
-if ($search_status=='') $search_status=1; // always display active customer first
-
-
-
-/*
- * Actions
- */
-
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
-if (empty($reshook))
-{
- if ($action == 'setstcomm')
- {
- $object = new Client($db);
- $result=$object->fetch($socid);
- $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
- $result=$object->set_commnucation_level($user);
- if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
-
- $action=''; $socid=0;
- }
-}
-
-
-/*
- * View
- */
-
-$formother=new FormOther($db);
-$form=new Form($db);
-$formcompany=new FormCompany($db);
-$prospectstatic=new Client($db);
-$prospectstatic->client=2;
-$prospectstatic->loadCacheOfProspStatus();
-
-$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias, s.zip, s.town, s.datec, s.status as status, s.code_client, s.client,";
-$sql.= " s.prefix_comm, s.fk_prospectlevel, s.fk_stcomm as stcomm_id,";
-$sql.= " st.libelle as stcomm_label,";
-$sql.= " d.nom as departement";
-$sql.= " ,s.fk_pays";
-$sql.= " ,typent.code as typent_code";
-if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
-// Add fields for extrafields
-if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
-// Add fields from hooks
-$parameters=array();
-$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
-$sql.=$hookmanager->resPrint;
-$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
-$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) ";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) ";
-if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
-if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
-$sql.= " WHERE s.fk_stcomm = st.id";
-$sql.= " AND s.client IN (2, 3)";
-$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')';
-if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc";
-if ($socid) $sql.= " AND s.rowid = " .$socid;
-if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2);
-if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
-if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
-if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
-if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
-if ($search_nom) $sql .= natural_search(array('s.nom','s.name_alias'), $search_nom);
-if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
-if ($search_town) $sql .= natural_search('s.town', $search_town);
-if ($search_state) $sql .= natural_search('d.nom', $search_state);
-if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
-if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status);
-// Insert levels filters
-if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
-if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
-if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
-// Insert sale filter
-if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
-if ($socname)
-{
- $sql .= natural_search('s.nom', $search_nom);
- $sortfield = "s.nom";
- $sortorder = "ASC";
-}
-// Add where from extra fields
-foreach ($search_array_options as $key => $val)
-{
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- $typ=$extrafields->attribute_type[$tmpkey];
- $mode=0;
- if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
- if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
- {
- $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
- }
-}
-// Add where from hooks
-$parameters=array();
-$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
-$sql.=$hookmanager->resPrint;
-// Count total nb of records
-$nbtotalofrecords = 0;
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
-}
-$sql.= " ORDER BY $sortfield $sortorder, s.nom ASC";
-$sql.= $db->plimit($conf->liste_limit+1, $offset);
-//print $sql;
-
-dol_syslog('comm/prospect/list.php', LOG_DEBUG);
-$resql = $db->query($sql);
-if ($resql)
-{
- $num = $db->num_rows($resql);
-
- if ($num == 1 && $socname)
- {
- $obj = $db->fetch_object($resql);
- header("Location: card.php?socid=".$obj->socid);
- exit;
- }
- else
- {
- $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
- llxHeader('',$langs->trans("ThirdParty"),$help_url);
- }
-
- $param='&search_stcomm='.$search_stcomm;
- $param.='&search_nom='.urlencode($search_nom);
- $param.='&search_zipcode='.urlencode($search_zipcode);
- $param.='&search_town='.urlencode($search_town);
- // Store the status filter in the URL
- if (isSet($search_setstcomm))
- {
- foreach ($search_setstcomm as $key => $value)
- {
- if ($value == 'true')
- $param.='&search_setstcomm['.((int) $key).']=true';
- else
- $param.='&search_setstcomm['.((int) $key).']=false';
- }
- }
- if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
- if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
- if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ);
- if ($search_sale > 0) $param.='&search_sale='.$search_sale;
- if ($search_status != '') $param.='&search_status='.$search_status;
- if ($search_country != '') $param.='&search_country='.$search_country;
- if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.$search_type_thirdparty;
- // Add $param from extra fields
- foreach ($search_array_options as $key => $val)
- {
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- $param.='&search_options_'.$tmpkey.'='.urlencode($val);
- }
-
- print_barre_liste($langs->trans("ListOfProspects"), $page, $_SERVER["PHP_SELF"], $param, $sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies.png');
-
-
- // Print the search-by-sale and search-by-categ filters
- print '";
-
- $db->free($resql);
-
- $parameters=array('sql' => $sql);
- $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-}
-else
-{
- dol_print_error($db);
-}
-
-
-llxFooter();
-$db->close();
diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php
index 500cf63b021..e3bc2a3fc2c 100644
--- a/htdocs/compta/bank/account.php
+++ b/htdocs/compta/bank/account.php
@@ -952,7 +952,7 @@ if ($id > 0 || ! empty($ref))
if ($sep > 0) print ' '; // If we had at least one line in future
else print $langs->trans("CurrentBalance");
print ' '.$object->currency_code.'';
- print '
';
print '';
} else {
@@ -961,9 +961,9 @@ if ($id > 0 || ! empty($ref))
if ($sep > 0) print ' '; // If we had at least one line in future
else print $langs->trans("Total");
print ' '.$object->currency_code.'';
- print '
';
@@ -231,8 +231,9 @@ if (empty($user->societe_id))
"SuppliersInvoices",
"ExpenseReports");
// Dashboard Link lines
- $links=array(DOL_URL_ROOT.'/comm/list.php',
- DOL_URL_ROOT.'/comm/prospect/list.php',
+ $links=array(
+ DOL_URL_ROOT.'/societe/list.php?type=c',
+ DOL_URL_ROOT.'/societe/list.php?type=p',
DOL_URL_ROOT.'/societe/list.php?type=f',
DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members',
DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products',
diff --git a/htdocs/install/doctemplates/invoices/template_invoice.odt b/htdocs/install/doctemplates/invoices/template_invoice.odt
index e9cd7c836fb..dad29a292ef 100644
Binary files a/htdocs/install/doctemplates/invoices/template_invoice.odt and b/htdocs/install/doctemplates/invoices/template_invoice.odt differ
diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
index 231b89ee507..accf65266c1 100644
--- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
+++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
@@ -86,5 +86,3 @@ CREATE TABLE IF NOT EXISTS llx_establishment (
status tinyint DEFAULT 1
) ENGINE=InnoDB;
-ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 0 AFTER ref_int;
-
diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql
index 796566fb638..e1fc421c911 100644
--- a/htdocs/install/mysql/tables/llx_user.sql
+++ b/htdocs/install/mysql/tables/llx_user.sql
@@ -26,7 +26,7 @@ create table llx_user
ref_ext varchar(50), -- reference into an external system (not used by dolibarr)
ref_int varchar(50), -- reference into an internal system (deprecated)
- employee tinyint DEFAULT 0, -- employee 0/1
+ employee tinyint DEFAULT 1, -- 1 if user is an employee
datec datetime,
tms timestamp,
@@ -76,7 +76,6 @@ create table llx_user
nb_holiday integer DEFAULT 0,
thm double(24,8),
tjm double(24,8),
- employee tinyint DEFAULT 1, -- 1 if user is an employee
salary double(24,8),
salaryextra double(24,8),
weeklyhours double(16,8)
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 7ea9f32830d..94e1fa60251 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -216,8 +216,8 @@ DateEcheance=Due date limit
DateInvoice=Invoice date
NoInvoice=No invoice
ClassifyBill=Classify invoice
-SupplierBillsToPay=Suppliers invoices to pay
-CustomerBillsUnpaid=Unpaid customers invoices
+SupplierBillsToPay=Unpaid supplier invoices
+CustomerBillsUnpaid=Unpaid customer invoices
NonPercuRecuperable=Non-recoverable
SetConditions=Set payment terms
SetMode=Set payment mode
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index e3fd6fadeec..3e93a48d7b5 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -305,7 +305,7 @@ ListOfCustomersContacts=List of customer contacts
ListOfSuppliersContacts=List of supplier contacts
ListOfCompanies=List of companies
ListOfThirdParties=List of third parties
-ShowCompany=Show company
+ShowCompany=Show thirdparty
ShowContact=Show contact
ContactsAllShort=All (No filter)
ContactType=Contact type
diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang
index 7414fcb7e62..14be1a6ade6 100644
--- a/htdocs/langs/en_US/workflow.lang
+++ b/htdocs/langs/en_US/workflow.lang
@@ -3,9 +3,9 @@ WorkflowSetup=Workflow module setup
WorkflowDesc=This module is designed to modify the behaviour of automatic actions into application. By default, workflow is open (you can do things in the order you want). You can activate the automatic actions you are interested in.
ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules.
descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed
-descWORKFLOW_PROPAL_AUTOCREATE_INVOICEAutomatically create a customer invoice after a commercial proposal is signed
-descWORKFLOW_CONTRACT_AUTOCREATE_INVOICEAutomatically create a customer invoice after a contract is validated
-descWORKFLOW_ORDER_AUTOCREATE_INVOICEAutomatically create a customer invoice after a customer order is closed
+descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed
+descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated
+descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a customer order is closed
descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer order is set to paid
descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid
descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index ffc7d7c4777..608957aa52d 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1485,14 +1485,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
// Add login user link
$toprightmenu.='
";
}
if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS))
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index 19301efd6e0..0e102af33f9 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -31,10 +31,12 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
$langs->load("companies");
$langs->load("customers");
$langs->load("suppliers");
+$langs->load("bills");
// Security check
$socid = GETPOST('socid','int');
@@ -64,10 +66,14 @@ $search_country=GETPOST("search_country",'int');
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
$search_type=GETPOST('search_type','alpha');
$search_status=GETPOST("search_status",'int');
+$search_level_from = GETPOST("search_level_from","alpha");
+$search_level_to = GETPOST("search_level_to","alpha");
+$search_stcomm=GETPOST('search_stcomm','int');
$type=GETPOST('type');
$optioncss=GETPOST('optioncss','alpha');
$mode=GETPOST("mode");
+$action=GETPOST('action');
$sortfield=GETPOST("sortfield",'alpha');
$sortorder=GETPOST("sortorder",'alpha');
@@ -116,6 +122,7 @@ if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp !=
if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod';
+
/*
* Actions
*/
@@ -126,6 +133,20 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+if (empty($reshook))
+{
+ if ($action == 'setstcomm')
+ {
+ $object = new Client($db);
+ $result=$object->fetch(GETPOST('stcommsocid'));
+ $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
+ $result=$object->set_commnucation_level($user);
+ if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
+
+ $action='';
+ }
+}
+
// special search
/*if ($mode == 'search')
{
@@ -176,20 +197,6 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
}
*/
-
-/*
- * View
- */
-
-$form=new Form($db);
-$formother=new FormOther($db);
-$companystatic=new Societe($db);
-$formcompany=new FormCompany($db);
-
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-llxHeader('',$langs->trans("ThirdParty"),$help_url);
-
-
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
@@ -212,14 +219,18 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_country='';
$search_type_thirdparty='';
$search_status='';
+ $search_stcomm='';
+ $search_level_from='';
+ $search_level_to='';
$search_array_options=array();
}
if ($search_status=='') $search_status=1; // always display active thirdparty first
+
/*
- * Mode List
+ * View
*/
/*
@@ -230,15 +241,105 @@ if ($search_status=='') $search_status=1; // always display active thirdparty fi
External user socid=x + Permission to see ALL customers => Can see only himself
External user socid=x + No permission to see ALL customers => Can see only himself
*/
+
+$form=new Form($db);
+$formother=new FormOther($db);
+$companystatic=new Societe($db);
+$formcompany=new FormCompany($db);
+$prospectstatic=new Client($db);
+$prospectstatic->client=2;
+$prospectstatic->loadCacheOfProspStatus();
+
+$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('',$langs->trans("ThirdParty"),$help_url);
+
+
$title=$langs->trans("ListOfThirdParties");
if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers");
if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects");
if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers");
-$sql = "SELECT s.rowid, s.nom as name, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, ";
-$sql.= " st.libelle as stcomm, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
-$sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4,";
-$sql.= " s.fk_pays, s.tms as date_update, s.datec as date_creation,";
+// If both parameters are set, search for everything BETWEEN them
+if ($search_level_from != '' && $search_level_to != '')
+{
+ // Ensure that these parameters are numbers
+ $search_level_from = (int) $search_level_from;
+ $search_level_to = (int) $search_level_to;
+
+ // If from is greater than to, reverse orders
+ if ($search_level_from > $search_level_to)
+ {
+ $tmp = $search_level_to;
+ $search_level_to = $search_level_from;
+ $search_level_from = $tmp;
+ }
+
+ // Generate the SQL request
+ $sortwhere = '(sortorder BETWEEN '.$search_level_from.' AND '.$search_level_to.') AS is_in_range';
+}
+// If only "from" parameter is set, search for everything GREATER THAN it
+else if ($search_level_from != '')
+{
+ // Ensure that this parameter is a number
+ $search_level_from = (int) $search_level_from;
+
+ // Generate the SQL request
+ $sortwhere = '(sortorder >= '.$search_level_from.') AS is_in_range';
+}
+// If only "to" parameter is set, search for everything LOWER THAN it
+else if ($search_level_to != '')
+{
+ // Ensure that this parameter is a number
+ $search_level_to = (int) $search_level_to;
+
+ // Generate the SQL request
+ $sortwhere = '(sortorder <= '.$search_level_to.') AS is_in_range';
+}
+// If no parameters are set, dont search for anything
+else
+{
+ $sortwhere = '0 as is_in_range';
+}
+
+// Select every potentiels, and note each potentiels which fit in search parameters
+dol_syslog('societe/list.php',LOG_DEBUG);
+$sql = "SELECT code, label, sortorder, ".$sortwhere;
+$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
+$sql.= " WHERE active > 0";
+$sql.= " ORDER BY sortorder";
+
+$resql = $db->query($sql);
+if ($resql)
+{
+ $tab_level = array();
+ $search_levels = array();
+
+ while ($obj = $db->fetch_object($resql))
+ {
+ // Compute level text
+ $level=$langs->trans($obj->code);
+ if ($level == $obj->code) $level=$langs->trans($obj->label);
+
+ // Put it in the array sorted by sortorder
+ $tab_level[$obj->sortorder] = $level;
+
+ // If this potentiel fit in parameters, add its code to the $search_levels array
+ if ($obj->is_in_range == 1)
+ {
+ $search_levels[] = '"'.preg_replace('[^A-Za-z0-9_-]', '', $obj->code).'"';
+ }
+ }
+
+ // Implode the $search_levels array so that it can be use in a "IN (...)" where clause.
+ // If no paramters was set, $search_levels will be empty
+ $search_levels = implode(',', $search_levels);
+}
+else dol_print_error($db);
+
+$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, ";
+$sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
+$sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4, s.fk_pays,";
+$sql.= " s.tms as date_update, s.datec as date_creation,";
$sql.= " typent.code as typent_code";
// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
@@ -291,6 +392,8 @@ if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status);
if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= " AND s.barcode LIKE '%".$db->escape($search_barcode)."%'";
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
+if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
+if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2);
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
@@ -348,6 +451,9 @@ if ($resql)
if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
+ if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm;
+ if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
+ if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
if ($type != '') $param.='&type='.urlencode($type);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
@@ -400,7 +506,7 @@ if ($resql)
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='
';
}
// If the user can view prospects other than his'
@@ -419,7 +525,7 @@ if ($resql)
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='
';
@@ -488,7 +601,9 @@ if ($resql)
if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
print_liste_field_titre(''); // type of customer
- // Extra fields
+ if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
+ // Extra fields
if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list))
{
foreach($extrafields->attribute_list as $key => $val)
@@ -503,9 +618,9 @@ if ($resql)
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
+ if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "\n";
@@ -623,6 +738,7 @@ if ($resql)
print '';
print '';
}
+
// Type (customer/prospect/supplier)
print '
';
+ $options_from = ''; // Generate in $options_from the list of each option sorted
+ foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
+ {
+ $options_from .= '';
+ }
+ array_reverse($tab_level, true); // Reverse the list
+ $options_to = ''; // Generate in $options_to the list of each option sorted in the reversed order
+ foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
+ {
+ $options_to .= '';
+ }
+
+ // Print these two select
+ print $langs->trans("From").' ';
+ print ' ';
+ print $langs->trans("to").' ';
+
+ print '
';
+ }
+
+ if (! empty($arrayfields['s.fk_stcomm']['checked']))
+ {
+ // Prospect status
+ print '
';
+ }
+
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- if (! empty($arrayfields['s.status']['checked']))
- {
- // Status
- print '
';
+ }
+
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- // Status
- if (! empty($arrayfields['s.status']['checked']))
+ // Date creation
+ if (! empty($arrayfields['s.datec']['checked']))
{
- print '
'.$companystatic->getLibStatut(3).'
';
- }
- if (! empty($arrayfields['s.datec']['checked']))
- {
- // Date creation
print '
';
}
- print "\n \n";
+ print "\n\n";
+
+
+ // Count total nb of records
+ $nbtotalofrecords = 0;
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
+ $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
+ }
+
+ $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
+ if ($result < 0)
+ {
+ setEventMessage($prodcustprice->error, 'errors');
+ }
+
+ $option = '&search_soc=' . $search_soc . '&id=' . $object->id;
+
+ print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
+
+ print '";
+
}
}
diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php
new file mode 100644
index 00000000000..6eb9765d034
--- /dev/null
+++ b/htdocs/societe/project.php
@@ -0,0 +1,156 @@
+
+ * Copyright (C) 2005 Brice Davoleau
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2006-2015 Laurent Destailleur
+ * Copyright (C) 2007 Patrick Raguin
+ * Copyright (C) 2010 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/societe/project.php
+ * \ingroup societe
+ * \brief Page of third party projects
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+
+$langs->load("companies");
+
+// Security check
+$socid = GETPOST('socid','int');
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'societe', $socid, '&societe');
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('projectthirdparty'));
+
+
+/*
+ * Actions
+ */
+
+$parameters=array('id'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+
+
+/*
+ * View
+ */
+
+$contactstatic = new Contact($db);
+
+$form = new Form($db);
+
+if ($socid)
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+
+ $langs->load("companies");
+
+
+ $object = new Societe($db);
+ $result = $object->fetch($socid);
+
+ $title=$langs->trans("Agenda");
+ if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
+ llxHeader('',$title);
+
+ if (! empty($conf->notification->enabled)) $langs->load("mails");
+ $head = societe_prepare_head($object);
+
+ dol_fiche_head($head, 'project', $langs->trans("ThirdParty"),0,'company');
+
+ dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+
+ print '
';
+
+ print '';
+ print '
';
+
+ // Alias names (commercial, trademark or alias names)
+ print '
'.$langs->trans('AliasNames').'
';
+ print $object->name_alias;
+ print "
";
+
+ if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
+ {
+ print '