From 196a745086c4fb7faab3bacc173ee8158b570bd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jul 2015 22:07:13 +0200 Subject: [PATCH 1/2] NEW Can filter proposal, orders or invoices with criteria "contain at least one product with following tag" --- htdocs/commande/list.php | 28 ++++++++++++++++++++++++---- htdocs/compta/facture/list.php | 29 ++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 1b3f8432b52..0ba8600e778 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -46,6 +46,7 @@ $orderyear=GETPOST("orderyear","int"); $ordermonth=GETPOST("ordermonth","int"); $deliveryyear=GETPOST("deliveryyear","int"); $deliverymonth=GETPOST("deliverymonth","int"); +$search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('search_ref','alpha')!=''?GETPOST('search_ref','alpha'):GETPOST('sref','alpha'); $search_ref_customer=GETPOST('search_ref_customer','alpha'); $search_company=GETPOST('search_company','alpha'); @@ -79,6 +80,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_categ=''; $search_user=''; $search_sale=''; + $search_product_category=''; $search_ref=''; $search_ref_customer=''; $search_company=''; @@ -115,10 +117,14 @@ $companystatic = new Societe($db); $help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; llxHeader('',$langs->trans("Orders"),$help_url); -$sql = 'SELECT s.nom as name, s.rowid as socid, s.client, s.code_client, c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; +$sql = 'SELECT'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +$sql.= ' s.nom as name, s.rowid as socid, s.client, s.code_client, c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as facturee'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; +if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -128,7 +134,8 @@ if ($search_user > 0) } $sql.= ' WHERE c.fk_soc = s.rowid'; $sql.= ' AND c.entity IN ('.getEntity('commande', 1).')'; -if ($socid) $sql.= ' AND s.rowid = '.$socid; +if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_ref) $sql .= natural_search('c.ref', $search_ref); if ($sall) $sql .= natural_search(array('c.ref', 'c.note_private'), $sall); @@ -260,15 +267,28 @@ if ($resql) if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); + $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); - $moreforfilter.='       '; + $moreforfilter.='
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.='
'; + } + // If the user can view prospects other than his' + if ($conf->categorie->enabled && $user->rights->produit->lire) + { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.='
'; } if (! empty($moreforfilter)) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a38049ae10f..fb2650b48ac 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -63,6 +63,7 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $lineid=GETPOST('lineid','int'); $userid=GETPOST('userid','int'); +$search_product_category=GETPOST('search_product_category','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'); @@ -121,6 +122,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_categ=''; $search_user=''; $search_sale=''; + $search_product_category=''; $search_ref=''; $search_refcustomer=''; $search_societe=''; @@ -144,8 +146,8 @@ $formfile = new FormFile($db); $bankaccountstatic=new Account($db); $facturestatic=new Facture($db); -if (! $sall) $sql = 'SELECT'; -else $sql = 'SELECT DISTINCT'; +$sql = 'SELECT'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' f.rowid as facid, f.facnumber, f.ref_client, f.type, f.note_private, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; @@ -155,6 +157,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $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 ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; +if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -165,7 +169,8 @@ if ($search_user > 0) $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; -if ($socid) $sql.= ' AND s.rowid = '.$socid; +if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($userid) { if ($userid == -1) $sql.=' AND f.fk_user_author IS NULL'; @@ -275,16 +280,30 @@ if ($resql) if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); + $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); - $moreforfilter.='       '; + $moreforfilter.='
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.='
'; } + // If the user can view prospects other than his' + if ($conf->categorie->enabled && $user->rights->produit->lire) + { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.='
'; + } + if ($moreforfilter) { print ''; From 312281f4d460ce06a3085ad8bb7c046340d5ca5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jul 2015 22:43:51 +0200 Subject: [PATCH 2/2] Debug askpricesupplier Try to continue work on position of menu entries. --- htdocs/comm/askpricesupplier/index.php | 2 +- htdocs/core/class/menu.class.php | 10 ++++++---- htdocs/core/class/menubase.class.php | 1 + htdocs/core/menus/standard/eldy.lib.php | 6 +++--- htdocs/core/modules/DolibarrModules.class.php | 5 +++-- htdocs/core/modules/modAskPriceSupplier.class.php | 9 ++++++--- htdocs/install/mysql/migration/repair.sql | 3 +++ htdocs/langs/en_US/askpricesupplier.lang | 2 ++ 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php index 2f943cef083..4eddadf3803 100644 --- a/htdocs/comm/askpricesupplier/index.php +++ b/htdocs/comm/askpricesupplier/index.php @@ -131,7 +131,7 @@ if ($resql) } if ($conf->use_javascript_ajax) { - print ''; + print ''; $data=array('series'=>$dataseries); dol_print_graph('stats',300,180,$data,1,'pie',1); print ''; diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index dff357d8f91..737e682bba3 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -58,11 +58,12 @@ class Menu * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) + * @param int $position Position (not used yet) * @return void */ - function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='') + function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) { - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu); + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position); } /** @@ -76,12 +77,13 @@ class Menu * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) + * @param int $position Position (not used yet) * @return void */ - function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='') + function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) { $array_start = array_slice($this->liste,0,($idafter+1)); - $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu)); + $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position)); $array_end = array_slice($this->liste,($idafter+1)); $this->liste=array_merge($array_start,$array_new,$array_end); } diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 0f0f715922e..2c21cb3c512 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -95,6 +95,7 @@ class Menubase $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); $this->user=trim($this->user); + $this->position=trim($this->position); if (! $this->level) $this->level=0; // Check parameters diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7f2640fad4a..e054264270b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -732,9 +732,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); - $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter'); - $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer); - $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire); + $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 200); + $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); + $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); } } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 472e260cfa6..734117d3bc4 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1370,10 +1370,11 @@ print $sql; $menu->target=$this->menu[$key]['target']; $menu->user=$this->menu[$key]['user']; $menu->enabled=isset($this->menu[$key]['enabled'])?$this->menu[$key]['enabled']:0; - + $menu->position=$this->menu[$key]['position']; + if (! $err) { - $result=$menu->create($user); + $result=$menu->create($user); // Save menu entry into table llx_menu if ($result > 0) { $this->menu[$key]['rowid']=$result; diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 451caccf649..371f2c9f214 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -148,7 +148,8 @@ class modAskPriceSupplier extends DolibarrModules 'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'$user->rights->askpricesupplier->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'user'=>2 // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + 'position'=>30 ); $r++; @@ -160,7 +161,8 @@ class modAskPriceSupplier extends DolibarrModules 'langs'=>'askpricesupplier', 'enabled'=>'$conf->askpricesupplier->enabled', 'perms'=>'$user->rights->askpricesupplier->creer', - 'user'=>2 + 'user'=>2, + 'position'=>31 ); $r++; @@ -172,7 +174,8 @@ class modAskPriceSupplier extends DolibarrModules 'langs'=>'askpricesupplier', 'enabled'=>'$conf->askpricesupplier->enabled', 'perms'=>'$user->rights->askpricesupplier->lire', - 'user'=>2 + 'user'=>2, + 'position'=>32 ); $r++; } diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 98fba06950d..22d441d70a5 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -227,3 +227,6 @@ update llx_facturedet set product_type = 1 where product_type = 2; delete from llx_commande_fournisseur_dispatch where fk_commandefourndet = 0 or fk_commandefourndet IS NULL; +delete from llx_menu where menu_handler = 'smartphone'; + + diff --git a/htdocs/langs/en_US/askpricesupplier.lang b/htdocs/langs/en_US/askpricesupplier.lang index 882b2fc2290..0cf337b96e6 100644 --- a/htdocs/langs/en_US/askpricesupplier.lang +++ b/htdocs/langs/en_US/askpricesupplier.lang @@ -33,12 +33,14 @@ AskpricesupplierStatusOpened=Validated (request is open) AskpricesupplierStatusClosed=Closed AskpricesupplierStatusSigned=Accepted AskpricesupplierStatusNotSigned=Refused +AskpricesupplierStatusBilled=Billed AskpricesupplierStatusDraftShort=Draft AskpricesupplierStatusValidatedShort=Validated AskpricesupplierStatusOpenedShort=Open AskpricesupplierStatusClosedShort=Closed AskpricesupplierStatusSignedShort=Accepted AskpricesupplierStatusNotSignedShort=Refused +AskpricesupplierStatusBilledShort=Billed CopyAskFrom=Create price request by copying existing a request CreateEmptyAsk=Create blank request CloneAsk=Clone price request