| '.$langs->trans('Ref').' | ';
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 45c4732f836..4a2ea5d326d 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -145,7 +145,7 @@ if ($id > 0 || ! empty($ref))
print '';
- $linkback=''.$langs->trans("BackToList").'';
+ $linkback=''.$langs->trans("BackToList").'';
// Ref
print '| '.$langs->trans('Ref').' | ';
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
new file mode 100644
index 00000000000..003c1c8419d
--- /dev/null
+++ b/htdocs/comm/propal/list.php
@@ -0,0 +1,404 @@
+
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2010-2011 Juanjo Menent
+ * Copyright (C) 2010-2011 Philippe Grand
+ * Copyright (C) 2012 Christophe Battarel
+*
+ * 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 2 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/propal.php
+ * \ingroup propale
+ * \brief Page of commercial proposals card and list
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formpropal.class.php");
+require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php');
+if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
+
+$langs->load('companies');
+$langs->load('propal');
+$langs->load('compta');
+$langs->load('bills');
+$langs->load('orders');
+$langs->load('products');
+
+$id=GETPOST('id','int');
+$ref=GETPOST('ref','alpha');
+$socid=GETPOST('socid','int');
+$action=GETPOST('action','alpha');
+$confirm=GETPOST('confirm','alpha');
+$lineid=GETPOST('lineid','int');
+
+$search_user=GETPOST('search_user','int');
+$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
+$search_refcustomer=GETPOST('search_refcustomer','alpha');
+$search_societe=GETPOST('search_societe','alpha');
+$search_montant_ht=GETPOST('search_montant_ht','alpha');
+
+$sall=GETPOST("sall");
+$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
+$year=GETPOST("year");
+$month=GETPOST("month");
+
+// Nombre de ligne pour choix de produit/service predefinis
+$NBLINES=4;
+
+// Security check
+$module='propale';
+if (isset($socid))
+{
+ $objectid=$socid;
+ $module='societe';
+ $dbtable='&societe';
+}
+else if (isset($id) && $id > 0)
+{
+ $objectid=$id;
+ $module='propale';
+ $dbtable='propal';
+}
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, $module, $objectid, $dbtable);
+
+$object = new Propal($db);
+
+// Load object
+if ($id > 0 || ! empty($ref))
+{
+ $ret=$object->fetch($id, $ref);
+}
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+$hookmanager=new HookManager($db);
+$hookmanager->initHooks(array('propalcard'));
+
+
+
+/*
+ * Actions
+ */
+
+// Do we click on purge search criteria ?
+if (GETPOST("button_removefilter_x"))
+{
+ $search_categ='';
+ $search_user='';
+ $search_ref='';
+ $search_refcustomer='';
+ $search_societe='';
+ $search_montant_ht='';
+ $year='';
+ $month='';
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
+
+$form = new Form($db);
+$formother = new FormOther($db);
+$formfile = new FormFile($db);
+$formpropal = new FormPropal($db);
+$companystatic=new Societe($db);
+
+$now=dol_now();
+
+$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;
+
+$viewstatut=$db->escape(GETPOST('viewstatut'));
+$object_statut = $db->escape(GETPOST('propal_statut'));
+if($object_statut != '')
+$viewstatut=$object_statut;
+
+if (! $sortfield) $sortfield='p.datep';
+if (! $sortorder) $sortorder='DESC';
+$limit = $conf->liste_limit;
+
+$sql = 'SELECT s.nom, s.rowid, s.client, ';
+$sql.= 'p.rowid as propalid, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
+if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
+$sql.= ' u.login';
+$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
+if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
+$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
+if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if ($search_user > 0)
+{
+ $sql.=", ".MAIN_DB_PREFIX."element_contact as c";
+ $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
+}
+$sql.= ' WHERE p.fk_soc = s.rowid';
+$sql.= ' AND p.entity = '.$conf->entity;
+
+if (! $user->rights->societe->client->voir && ! $socid) //restriction
+{
+ $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+}
+if ($search_ref)
+{
+ $sql.= " AND p.ref LIKE '%".$db->escape(trim($search_ref))."%'";
+}
+if ($search_refcustomer)
+{
+ $sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'";
+}
+if ($search_societe)
+{
+ $sql.= " AND s.nom LIKE '%".$db->escape(trim($search_societe))."%'";
+}
+if ($search_montant_ht)
+{
+ $sql.= " AND p.total_ht='".$db->escape(trim($search_montant_ht))."'";
+}
+if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%' OR pd.description LIKE '%".$db->escape($sall)."%')";
+if ($socid) $sql.= ' AND s.rowid = '.$socid;
+if ($viewstatut <> '')
+{
+ $sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
+}
+if ($month > 0)
+{
+ if ($year > 0 && empty($day))
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
+ else if ($year > 0 && ! empty($day))
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+ else
+ $sql.= " AND date_format(p.datep, '%m') = '".$month."'";
+}
+else if ($year > 0)
+{
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
+}
+if ($search_user > 0)
+{
+ $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user;
+}
+
+
+$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC';
+$sql.= $db->plimit($limit + 1,$offset);
+$result=$db->query($sql);
+
+if ($result)
+{
+ $objectstatic=new Propal($db);
+ $userstatic=new User($db);
+
+ $num = $db->num_rows($result);
+
+ if ($socid)
+ {
+ $soc = new Societe($db);
+ $soc->fetch($socid);
+ }
+
+ $param='&socid='.$socid.'&viewstatut='.$viewstatut;
+ if ($month) $param.='&month='.$month;
+ if ($year) $param.='&year='.$year;
+ if ($search_ref) $param.='&search_ref=' .$search_ref;
+ if ($search_refcustomer) $param.='&search_ref=' .$search_refcustomer;
+ if ($search_societe) $param.='&search_societe=' .$search_societe;
+ if ($search_user > 0) $param.='&search_user='.$search_user;
+ if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
+ print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->nom:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num);
+
+ // Lignes des champs de filtre
+ print '';
+
+ $db->free($result);
+}
+else
+{
+ dol_print_error($db);
+}
+
+// End of page
+llxFooter();
+$db->close();
+?>
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index fde8d2411d3..d7d88029062 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -86,7 +86,7 @@ if ($id > 0 || ! empty($ref))
print '';
- $linkback="".$langs->trans("BackToList")."";
+ $linkback="".$langs->trans("BackToList")."";
// Ref
print '| '.$langs->trans('Ref').' | ';
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 16eb5c44094..65306b7efb1 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2361,7 +2361,8 @@ class Commande extends CommonObject
$clause = " AND";
}
$sql.= $clause." c.entity = ".$conf->entity;
- $sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
+ //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
+ $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql);
diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php
index ad32f3e39de..82a146038f1 100644
--- a/htdocs/commande/liste.php
+++ b/htdocs/commande/liste.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
*
@@ -42,6 +42,7 @@ $sref_client=GETPOST('sref_client','alpha');
$snom=GETPOST('snom','alpha');
$sall=GETPOST('sall');
$socid=GETPOST('socid','int');
+$search_user=GETPOST('search_user','int');
// Security check
$id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int'));
@@ -80,6 +81,11 @@ $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ', '.MAIN_DB_PREFIX.'commande as c';
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if ($search_user > 0)
+{
+ $sql.=", ".MAIN_DB_PREFIX."element_contact as ec";
+ $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
+}
$sql.= ' WHERE c.fk_soc = s.rowid';
$sql.= ' AND c.entity = '.$conf->entity;
if ($socid) $sql.= ' AND s.rowid = '.$socid;
@@ -108,24 +114,35 @@ if ($viewstatut <> '')
}
if ($viewstatut == -2) // To process
{
- $sql .= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
+ //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
+ $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
}
}
if ($ordermonth > 0)
{
- $sql.= " AND date_format(c.date_valid, '%Y-%m') = '".$orderyear."-".$ordermonth."'";
+ if ($orderyear > 0 && empty($day))
+ $sql.= " AND c.date_valid BETWEEN '".$db->idate(dol_get_first_day($orderyear,$ordermonth,false))."' AND '".$db->idate(dol_get_last_day($orderyear,$ordermonth,false))."'";
+ else if ($orderyear > 0 && ! empty($day))
+ $sql.= " AND c.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $ordermonth, $day, $orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $ordermonth, $day, $orderyear))."'";
+ else
+ $sql.= " AND date_format(c.date_valid, '%m') = '".$ordermonth."'";
}
-if ($orderyear > 0)
+else if ($orderyear > 0)
{
- $sql.= " AND date_format(c.date_valid, '%Y') = '".$orderyear."'";
+ $sql.= " AND c.date_valid BETWEEN '".$db->idate(dol_get_first_day($orderyear,1,false))."' AND '".$db->idate(dol_get_last_day($orderyear,12,false))."'";
}
if ($deliverymonth > 0)
{
- $sql.= " AND date_format(c.date_livraison, '%Y-%m') = '".$deliveryyear."-".$deliverymonth."'";
+ if ($deliveryyear > 0 && empty($day))
+ $sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,$deliverymonth,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,$deliverymonth,false))."'";
+ else if ($deliveryyear > 0 && ! empty($day))
+ $sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $deliverymonth, $day, $deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $deliverymonth, $day, $deliveryyear))."'";
+ else
+ $sql.= " AND date_format(c.date_livraison, '%m') = '".$deliverymonth."'";
}
-if ($deliveryyear > 0)
+else if ($deliveryyear > 0)
{
- $sql.= " AND date_format(c.date_livraison, '%Y') = '".$deliveryyear."'";
+ $sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,1,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,12,false))."'";
}
if (!empty($snom))
{
@@ -135,12 +152,16 @@ if (!empty($sref_client))
{
$sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\'';
}
+if ($search_user > 0)
+{
+ $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
+}
$sql.= ' ORDER BY '.$sortfield.' '.$sortorder;
$sql.= $db->plimit($limit + 1,$offset);
+//print $sql;
$resql = $db->query($sql);
-
if ($resql)
{
if ($socid)
@@ -168,20 +189,45 @@ if ($resql)
if ($viewstatut == -2)
$title.=' - '.$langs->trans('StatusOrderToProcessShort');
+ $param='&socid='.$socid.'&viewstatut='.$viewstatut;
+ if ($month) $param.='&month='.$month;
+ if ($year) $param.='&year='.$year;
+ if ($sref) $param.='&sref='.$sref;
+ if ($snom) $param.='&snom='.$snom;
+ if ($sref_client) $param.='&sref_client='.$sref_client;
+ if ($search_user > 0) $param.='&search_user='.$search_user;
+
$num = $db->num_rows($resql);
- print_barre_liste($title, $page, 'liste.php','&socid='.$socid.'&viewstatut='.$viewstatut,$sortfield,$sortorder,'',$num);
+ print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num);
$i = 0;
- print '';
- print '';
- print_liste_field_titre($langs->trans('Ref'),'liste.php','c.ref','','&socid='.$socid.'&viewstatut='.$viewstatut,'width="25%"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('Company'),'liste.php','s.nom','','&socid='.$socid.'&viewstatut='.$viewstatut,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('RefCustomerOrder'),'liste.php','c.ref_client','','&socid='.$socid.'&viewstatut='.$viewstatut,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('OrderDate'),'liste.php','c.date_commande','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('DeliveryDate'),'liste.php','c.date_livraison','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('Status'),'liste.php','c.fk_statut','','&socid='.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder);
- print ' ';
+
// Lignes des champs de filtre
- print '';
+
$db->free($resql);
}
else
@@ -274,7 +323,7 @@ else
print dol_print_error($db);
}
-$db->close();
-
llxFooter();
+
+$db->close();
?>
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 814ca85636f..937ec9b4b55 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -7,7 +7,7 @@
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2010-2011 Juanjo Menent
* Copyright (C) 2012 Christophe Battarel
-**
+ *
* 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 2 of the License, or
@@ -143,53 +143,53 @@ else if ($action == 'reopen' && $user->rights->facture->creer)
// Delete invoice
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
- $result = $object->fetch($id);
- $result = $object->delete();
- if ($result > 0)
- {
- Header('Location: '.$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $mesg=''.$object->error.' ';
+ $result = $object->fetch($id);
+ $result = $object->delete();
+ if ($result > 0)
+ {
+ Header('Location: '.$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $mesg=''.$object->error.' ';
}
}
// Delete line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
-
- $result = $object->deleteline($_GET['lineid'], $user);
- if ($result > 0)
- {
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
- $ret=$object->fetch($id); // Reload to get new records
- $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
- }
- if ($result >= 0)
- {
- Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
- exit;
- }
- }
- else
- {
- $mesg=''.$object->error.' ';
- $action='';
+ $object->fetch($id);
+ $object->fetch_thirdparty();
+
+ $result = $object->deleteline($_GET['lineid'], $user);
+ if ($result > 0)
+ {
+ // Define output language
+ $outputlangs = $langs;
+ $newlang='';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
+ $ret=$object->fetch($id); // Reload to get new records
+ $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+ }
+ if ($result >= 0)
+ {
+ Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
+ exit;
+ }
+ }
+ else
+ {
+ $mesg=''.$object->error.' ';
+ $action='';
}
}
@@ -310,18 +310,18 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer)
$object->set_ref_client($_POST['ref_client']);
}
-else if ($action == 'setnote_public' && $user->rights->facture->creer)
-{
- $object->fetch($id);
- $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
-else if ($action == 'setnote' && $user->rights->facture->creer)
-{
- $object->fetch($id);
- $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
+else if ($action == 'setnote_public' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
+}
+
+else if ($action == 'setnote' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
}
// Classify to validated
@@ -1506,64 +1506,64 @@ else if ($action == 'builddoc') // En get ou en post
}
}
-if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
- if ($action == 'addcontact' && $user->rights->facture->creer)
- {
- $result = $object->fetch($id);
-
- if ($result > 0 && $id > 0)
+ if ($action == 'addcontact' && $user->rights->facture->creer)
+ {
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
{
- $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
- }
-
- if ($result >= 0)
- {
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else
- {
- if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
- $langs->load("errors");
- $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").' ';
- }
- else
- {
- $mesg = ''.$object->error.' ';
- }
- }
- }
-
- // bascule du statut d'un contact
- else if ($action == 'swapstatut' && $user->rights->facture->creer)
- {
- if ($object->fetch($id))
- {
- $result=$object->swapContactStatus(GETPOST('ligne'));
- }
- else
- {
- dol_print_error($db);
- }
- }
-
- // Efface un contact
- else if ($action == 'deletecontact' && $user->rights->facture->creer)
- {
- $object->fetch($id);
- $result = $object->delete_contact($lineid);
-
- if ($result >= 0)
- {
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else {
- dol_print_error($db);
- }
+ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+ $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
+ }
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else
+ {
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").' ';
+ }
+ else
+ {
+ $mesg = ''.$object->error.' ';
+ }
+ }
+ }
+
+ // bascule du statut d'un contact
+ else if ($action == 'swapstatut' && $user->rights->facture->creer)
+ {
+ if ($object->fetch($id))
+ {
+ $result=$object->swapContactStatus(GETPOST('ligne'));
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+
+ // Efface un contact
+ else if ($action == 'deletecontact' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ $result = $object->delete_contact($lineid);
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else {
+ dol_print_error($db);
+ }
}
}
@@ -2309,6 +2309,30 @@ else
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '';
+ // Ref customer
+ print '| ';
+ print '';
+ print ' | ';
+ print '';
+ if ($user->rights->facture->creer && $action == 'refclient')
+ {
+ print '';
+ }
+ else
+ {
+ print $object->ref_client;
+ }
+ print ' | ';
+
// Third party
print '';
print '';
@@ -2801,22 +2825,22 @@ else
print ' ';
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
- require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
- require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
- $formcompany= new FormCompany($db);
-
- $blocname = 'contacts';
- $title = $langs->trans('ContactsAddresses');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
- }
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
- $blocname = 'notes';
- $title = $langs->trans('Notes');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+ $formcompany= new FormCompany($db);
+
+ $blocname = 'contacts';
+ $title = $langs->trans('ContactsAddresses');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ }
+
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ $blocname = 'notes';
+ $title = $langs->trans('Notes');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
@@ -3231,6 +3255,7 @@ else
$pageprev = $page - 1;
$pagenext = $page + 1;
+ $search_user = GETPOST('search_user','int');
$day = GETPOST('day','int');
$month = GETPOST('month','int');
$year = GETPOST('year','int');
@@ -3249,6 +3274,11 @@ else
$sql.= ', '.MAIN_DB_PREFIX.'facture as f';
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid';
+ if ($search_user > 0)
+ {
+ $sql.=", ".MAIN_DB_PREFIX."element_contact as ec";
+ $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
+ }
$sql.= ' WHERE f.fk_soc = s.rowid';
$sql.= " AND f.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@@ -3296,6 +3326,10 @@ else
{
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
+ if ($search_user > 0)
+ {
+ $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user;
+ }
if (! $sall)
{
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.increment, f.total, f.total_ttc,';
@@ -3325,19 +3359,38 @@ else
$soc->fetch($socid);
}
- $param='&socid='.$socid;
- if ($month) $param.='&month='.$month;
- if ($year) $param.='&year=' .$year;
-
- print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->nom:''),$page,'facture.php',$param,$sortfield,$sortorder,'',$num);
+ $param='&socid='.$socid;
+ if ($month) $param.='&month='.$month;
+ if ($year) $param.='&year=' .$year;
+ if ($search_ref) $param.='&search_ref=' .$search_ref;
+ if ($search_societe) $param.='&search_societe=' .$search_societe;
+ if ($search_user > 0) $param.='&search_user=' .$search_user;
+ if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
+ if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc;
+ print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->nom:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num);
$i = 0;
- print ' | | | |