diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index b636c8bd3b7..ad6bb5dafec 100755 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -104,9 +104,9 @@ if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ -if ($search_nom) $sql.= " AND s.nom like '%".$db->escape(strtolower($search_nom))."%'"; -if ($search_ville) $sql.= " AND s.ville like '%".$db->escape(strtolower($search_ville))."%'"; -if ($search_code) $sql.= " AND s.code_client like '%".$db->escape(strtolower($search_code))."%'"; +if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'"; +if ($search_ville) $sql.= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'"; +if ($search_code) $sql.= " AND s.code_client LIKE '%".$db->escape(strtolower($search_code))."%'"; if ($search_compta) $sql .= " AND s.code_compta LIKE '%".$db->escape($search_compta)."%'"; // Insert sale filter if ($search_sale) @@ -120,7 +120,7 @@ if ($search_categ) } if ($socname) { - $sql.= " AND s.nom like '%".$db->escape(strtolower($socname))."%'"; + $sql.= " AND s.nom LIKE '%".$db->escape(strtolower($socname))."%'"; $sortfield = "s.nom"; $sortorder = "ASC"; } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4922fcc7225..e20d67c95ab 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -55,6 +55,7 @@ $confirm=GETPOST('confirm','alpha'); $lineid=GETPOST('lineid','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'); @@ -1567,16 +1568,12 @@ if ($id > 0 || ! empty($ref)) include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'); } - // TODO test using div instead of tables - //print '
'; print ''; // Show object lines $result = $object->getLinesArray(); if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); - //print '
'; - /* * Form to add new line */ @@ -1601,9 +1598,7 @@ if ($id > 0 || ! empty($ref)) } } - // TODO test using div instead of tables print '
'; - //print '
'; print ''; print "\n"; @@ -1872,18 +1867,18 @@ else $limit = $conf->liste_limit; $sql = 'SELECT s.nom, s.rowid, s.client, '; - $sql.= 'p.rowid as propalid, p.total_ht, p.ref, 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.= '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 (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ')'; 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'; $sql.= ' WHERE p.fk_soc = s.rowid'; $sql.= ' AND p.entity = '.$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) //restriction + if (! $user->rights->societe->client->voir && ! $socid) //restriction { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } @@ -1891,6 +1886,10 @@ else { $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))."%'"; @@ -1944,6 +1943,7 @@ else print ''; print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'p.ref_client','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); @@ -1961,11 +1961,13 @@ else print ''; print ''; print ''; + print ''; + print ''; + print ''; print ''; print $langs->trans('Month').': '; print ' '.$langs->trans('Year').': '; $syear = $year; - //if($syear == '') $syear = date("Y"); $formother->select_year($syear,'year',1, 20, 5); print ''; print ' '; @@ -2026,6 +2028,11 @@ else print ''; print $companystatic->getNomUrl(1,'customer'); print ''; + + // Customer ref + print ''; + print $objp->ref_client; + print ''; // Date propale print ''; diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index d628610b94c..ad32f3e39de 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3d50a867fe1..8e5cb7bbc98 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2347,183 +2347,159 @@ abstract class CommonObject /* This is to show array of line of details */ - /** - * Return HTML table for object lines - * TODO Move this into an output class file (htmlline.class.php) - * If lines are into a template, title must also be into a template - * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. - * - * @param string $action Action code - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected - * @param int $dateSelector 1=Show also date range input fields - * @param HookManager $hookmanager Hookmanager - * @return void - */ - function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false) - { - global $conf,$langs; - - // TODO test using div instead of tables - /* - print '
'; - print '
'; - print '
'; - print '
'.$langs->trans('Description').'
'; - print '
'.$langs->trans('VAT').'
'; - print '
'.$langs->trans('PriceUHT').'
'; - print '
'.$langs->trans('Qty').'
'; - print '
'.$langs->trans('ReductionShort').'
'; - print '
'.$langs->trans('TotalHTShort').'
'; - print '
 
'; - print '
 
'; - print '
 
'; - print '
'; - */ - - print ''; - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - { - print ' '; - } - print ''.$langs->trans('Description').''; - print ''.$langs->trans('VAT').''; - print ''.$langs->trans('PriceUHT').''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ''.$langs->trans('TotalHTShort').''; - print ' '; - print ' '; - print ' '; // No width to allow autodim - print "\n"; - - $num = count($this->lines); - $var = true; - $i = 0; - - //print '
'; - - foreach ($this->lines as $line) - { - $var=!$var; - - if (is_object($hookmanager) && ( ($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line) ) ) - { - if (empty($line->fk_parent_line)) - { - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected); - $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - } - } - else - { - $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); - } - - $i++; - } - - //print '
'; - } - - /** - * Return HTML content of a detail line - * TODO Move this into an output class file (htmlline.class.php) - * If lines are into a template, title must also be into a template - * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. - * - * @param string $action GET/POST action - * @param array $line Selected object line to output - * @param string $var Is it a an odd line (true) - * @param int $num Number of line (0) - * @param int $i I - * @param int $dateSelector 1=Show also date range input fields - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected - * @param HookManager $hookmanager Hook manager - * @return void + /** + * Return HTML table for object lines + * TODO Move this into an output class file (htmlline.class.php) + * If lines are into a template, title must also be into a template + * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. + * + * @param string $action Action code + * @param string $seller Object of seller third party + * @param string $buyer Object of buyer third party + * @param string $selected Object line selected + * @param int $dateSelector 1=Show also date range input fields + * @param HookManager $hookmanager Hookmanager + * @return void + */ + function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false) + { + global $conf,$langs; + + print ''; + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ' '; + } + print ''.$langs->trans('Description').''; + print ''.$langs->trans('VAT').''; + print ''.$langs->trans('PriceUHT').''; + print ''.$langs->trans('Qty').''; + print ''.$langs->trans('ReductionShort').''; + print ''.$langs->trans('TotalHTShort').''; + print ' '; + print ' '; + print ' '; // No width to allow autodim + print "\n"; + + $num = count($this->lines); + $var = true; + $i = 0; + + foreach ($this->lines as $line) + { + $var=!$var; + + if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + { + if (empty($line->fk_parent_line)) + { + $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected); + $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + } + } + else + { + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); + } + + $i++; + } + } + + /** + * Return HTML content of a detail line + * TODO Move this into an output class file (htmlline.class.php) + * If lines are into a template, title must also be into a template + * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * + * @param string $action GET/POST action + * @param array $line Selected object line to output + * @param string $var Is it a an odd line (true) + * @param int $num Number of line (0) + * @param int $i I + * @param int $dateSelector 1=Show also date range input fields + * @param string $seller Object of seller third party + * @param string $buyer Object of buyer third party + * @param string $selected Object line selected + * @param HookManager $hookmanager Hook manager + * @return void */ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$hookmanager=false) { global $conf,$langs,$user; global $form,$bc,$bcdd; - - $element = $this->element; - if ($element == 'propal') $element = 'propale'; // To work with non standard path - - // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; - - // Ligne en mode visu - if ($action != 'editline' || $selected != $line->id) - { - // Produit - if ($line->fk_product > 0) - { - $product_static = new Product($this->db); - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $this->fetch_thirdparty(); - $prod = new Product($this->db, $line->fk_product); - - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if (empty($newlang)) $newlang=$this->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label; - } - else { - $label = $line->product_label; - } - - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->libelle=$label; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - - // Use global variables + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php'); - //include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductlinediv_view.tpl.php'); - } - else - { - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php'); - } - } - - // Ligne en mode update - if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) - { - if ($line->fk_product > 0) - { - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.tpl.php'); - } - else - { - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.tpl.php'); - } - } - } + + // Show product and description + $type=$line->product_type?$line->product_type:$line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($line->date_start)) $type=1; + if (! empty($line->date_end)) $type=1; + + // Ligne en mode visu + if ($action != 'editline' || $selected != $line->id) + { + // Produit + if ($line->fk_product > 0) + { + $product_static = new Product($this->db); + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $this->fetch_thirdparty(); + $prod = new Product($this->db, $line->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$this->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label; + } + else + { + $label = $line->product_label; + } + + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->libelle=$label; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); + + // Use global variables + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php'); + } + else + { + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php'); + } + } + + // Ligne en mode update + if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) + { + if ($line->fk_product > 0) + { + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.tpl.php'); + } + else + { + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.tpl.php'); + } + } + } /* This is to show array of line of details of source object */ diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index e2d7ed35ea8..e7f5837ac12 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -688,7 +688,7 @@ class FormOther $currentyear = date("Y")+$offset; $max_year = $currentyear+$max_year; $min_year = $currentyear-$min_year; - if(empty($selected)) $selected = $currentyear; + if(empty($selected) && empty($useempty)) $selected = $currentyear; $out.= '