From 52952c6fceeeb779765ab8fe9208c2db9d04e133 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Apr 2013 15:08:35 +0200 Subject: [PATCH] Uniformize code for liste_array Fix visibility of elements into product page (manage external users) --- htdocs/comm/fiche.php | 8 +- htdocs/comm/propal/class/propal.class.php | 66 +-- htdocs/comm/propal/list.php | 2 +- htdocs/commande/class/commande.class.php | 56 ++- htdocs/commande/fiche.php | 50 +- htdocs/compta/facture/class/facture.class.php | 76 ++- htdocs/core/class/hookmanager.class.php | 4 +- htdocs/core/class/html.formfile.class.php | 2 - htdocs/core/search_page.php | 23 +- htdocs/langs/fr_FR/products.lang | 2 +- htdocs/langs/fr_FR/propal.lang | 2 +- htdocs/product/fiche.php | 433 ++++-------------- 12 files changed, 300 insertions(+), 424 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 88b136b8167..fd95ced8746 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -441,12 +441,12 @@ if ($id > 0) print ""; - + print '
'; //print "\n"; //print ''; - + // Nbre max d'elements des petites listes $MAXLIST=4; $tableaushown=1; @@ -469,10 +469,6 @@ if ($id > 0) { $propal_static = new Propal($db); - $proposals = $propal_static->liste_array(0, 0, 0, $object->id, $MAXLIST); - - //var_dump($proposals); - $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; $sql.= " p.datep as dp, p.fin_validite as datelimite"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 92664782f3f..92c1e6127ed 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -307,8 +307,8 @@ class Propal extends CommonObject * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price without tax * @param string $label ??? - * @param timestamp $date_start Start date of the line - * @param timestamp $date_end End date of the line + * @param timestamp $date_start Start date of the line + * @param timestamp $date_end End date of the line * @return int >0 if OK, <0 if KO * * @see add_product @@ -403,7 +403,7 @@ class Propal extends CommonObject $this->line->product_type=$type; $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; - + $this->line->date_start=$date_start; $this->line->date_end=$date_end; @@ -470,8 +470,8 @@ class Propal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param timestamp $date_start Start date of the line - * @param timestamp $date_end End date of the line + * @param timestamp $date_start Start date of the line + * @param timestamp $date_end End date of the line * @return int 0 if OK, <0 if KO */ function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='') @@ -552,7 +552,7 @@ class Propal extends CommonObject // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; - + $this->line->date_start=$date_start; $this->line->date_end=$date_end; @@ -830,7 +830,7 @@ class Propal extends CommonObject } } else if ($reshook < 0) $error++; - + if (! $notrigger) { // Appel des triggers @@ -1164,7 +1164,7 @@ class Propal extends CommonObject $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; - + $line->date_start = $objp->date_start; $line->date_end = $objp->date_end; @@ -1195,7 +1195,7 @@ class Propal extends CommonObject foreach($extrafields->attribute_label as $key=>$label) { $this->array_options['options_'.$key]=$label; - } + } return 1; } @@ -1209,7 +1209,7 @@ class Propal extends CommonObject return -1; } } - + /** * Update value of extrafields on the proposal * @@ -1235,7 +1235,7 @@ class Propal extends CommonObject } } else if ($reshook < 0) $error++; - + if (!$error) { return 1; @@ -1244,7 +1244,7 @@ class Propal extends CommonObject { return -1; } - + } /** @@ -1262,16 +1262,16 @@ class Propal extends CommonObject $now=dol_now(); if ($user->rights->propale->valider) - { + { $this->db->begin(); - + // Numbering module definition $soc = new Societe($this->db); $soc->fetch($this->socid); - + // Class of company linked to propal $result=$soc->set_as_client(); - + // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) { @@ -1648,7 +1648,7 @@ class Propal extends CommonObject $this->db->rollback(); return -2; } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1674,7 +1674,7 @@ class Propal extends CommonObject } else { - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1688,7 +1688,7 @@ class Propal extends CommonObject //$ret=$object->fetch($id); // Reload to get new records propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -1769,9 +1769,9 @@ class Propal extends CommonObject /** * Return list of proposal (eventually filtered on user) into an array * - * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref) + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) * @param int $draft 0=not draft, 1=draft - * @param int $notcurrentuser 0=current user, 1=not current user + * @param int $notcurrentuser 0=all user, 1=not current user * @param int $socid Id third pary * @param int $limit For pagination * @param int $offset For pagination @@ -1785,15 +1785,22 @@ class Propal extends CommonObject $ga = array(); - $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql.= " p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; $sql.= " p.datep as dp, p.fin_validite as datelimite"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; + if (! $user->rights->societe->client->voir && ! $socid) //restriction + { + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } if ($socid) $sql.= " AND s.rowid = ".$socid; if ($draft) $sql.= " AND p.fk_statut = 0"; - if ($notcurrentuser) $sql.= " AND p.fk_user_author <> ".$user->id; + if ($notcurrentuser > 0) $sql.= " AND p.fk_user_author <> ".$user->id; $sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->plimit($limit,$offset); @@ -1808,14 +1815,19 @@ class Propal extends CommonObject { $obj = $this->db->fetch_object($result); - if ($shortlist) + if ($shortlist == 1) { $ga[$obj->propalid] = $obj->ref; } - else + else if ($shortlist == 2) { + $ga[$obj->propalid] = $obj->ref.' ('.$obj->name.')'; + } + else + { $ga[$i]['id'] = $obj->propalid; $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; } $i++; @@ -2640,7 +2652,7 @@ class PropaleLigne var $localtax2_tx; var $total_localtax1; var $total_localtax2; - + var $date_start; var $date_end; @@ -2713,7 +2725,7 @@ class PropaleLigne $this->libelle = $objp->product_label; // deprecated $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; - + $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 4787cb3ae3e..2e3b70a8ca3 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -131,7 +131,7 @@ if (! $sortfield) $sortfield='p.datep'; if (! $sortorder) $sortorder='DESC'; $limit = $conf->liste_limit; -$sql = 'SELECT s.nom, s.rowid, s.client, '; +$sql = 'SELECT s.rowid, s.nom, 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'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9be91fd80e5..e186c7753a7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -761,7 +761,7 @@ class Commande extends CommonOrder } } } - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -933,7 +933,7 @@ class Commande extends CommonOrder $line->rang = $object->lines[$i]->rang; $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - + $line->date_start = $object->lines[$i]->date_start; $line->date_end = $object->lines[$i]->date_end; @@ -1972,23 +1972,38 @@ class Commande extends CommonOrder /** * Return list of orders (eventuelly filtered on a user) into an array * - * @param int $brouillon 0=non brouillon, 1=brouillon - * @param User $user Objet user de filtre + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param User $excluser Objet user to exclude + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($brouillon=0, $user='') + function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC') { - global $conf; + global $conf,$user; $ga = array(); - $sql = "SELECT s.nom, s.rowid, c.rowid, c.ref"; + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql.= " c.rowid as cid, c.ref"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.entity = ".$conf->entity; $sql.= " AND c.fk_soc = s.rowid"; - if ($brouillon) $sql.= " AND c.fk_statut = 0"; - if ($user) $sql.= " AND c.fk_user_author <> ".$user->id; - $sql .= " ORDER BY c.date_commande DESC"; + if (! $user->rights->societe->client->voir && ! $socid) //restriction + { + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($draft) $sql.= " AND c.fk_statut = 0"; + if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id; + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit,$offset); $result=$this->db->query($sql); if ($result) @@ -2001,7 +2016,20 @@ class Commande extends CommonOrder { $obj = $this->db->fetch_object($result); - $ga[$obj->rowid] = $obj->ref; + if ($shortlist == 1) + { + $ga[$obj->cid] = $obj->ref; + } + else if ($shortlist == 2) + { + $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')'; + } + else + { + $ga[$i]['id'] = $obj->cid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } $i++; } } @@ -2781,7 +2809,7 @@ class Commande extends CommonOrder return -1; } } - + /** * Update value of extrafields on the proposal * @@ -2807,7 +2835,7 @@ class Commande extends CommonOrder } } else if ($reshook < 0) $error++; - + if (!$error) { return 1; @@ -2816,7 +2844,7 @@ class Commande extends CommonOrder { return -1; } - + } /** diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1166dcbd8e1..ea2cd608452 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1,34 +1,34 @@ * Copyright (C) 2004-2013 Laurent Destailleur -* Copyright (C) 2005 Marc Barilley / Ocebo -* Copyright (C) 2005-2013 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2010-2013 Juanjo Menent -* Copyright (C) 2011 Philippe Grand -* Copyright (C) 2012 Christophe Battarel -* Copyright (C) 2012 Marcos García -* Copyright (C) 2013 Florian Henry -* -* 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 . -*/ + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Marcos García + * Copyright (C) 2013 Florian Henry + * + * 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/commande/fiche.php -* \ingroup commande -* \brief Page to show customer order -*/ + * \ingroup commande + * \brief Page to show customer order + */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a2a9cf6da13..a538694bac9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1302,7 +1302,7 @@ class Facture extends CommonInvoice { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - + $num=count($this->lines); for ($i = 0; $i < $num; $i++) { @@ -2664,6 +2664,80 @@ class Facture extends CommonInvoice } + /** + * Return list of invoices (eventually filtered on a user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param User $excluser Objet user to exclude + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC') + { + global $conf,$user; + + $ga = array(); + + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) //restriction + { + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($draft) $sql.= " AND f.fk_statut = 0"; + if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit,$offset); + + $result=$this->db->query($sql); + if ($result) + { + $numc = $this->db->num_rows($result); + if ($numc) + { + $i = 0; + while ($i < $numc) + { + $obj = $this->db->fetch_object($result); + + if ($shortlist == 1) + { + $ga[$obj->fid] = $obj->ref; + } + else if ($shortlist == 2) + { + $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; + } + else + { + $ga[$i]['id'] = $obj->fid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } + $i++; + } + } + return $ga; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** * Renvoi liste des factures remplacables * Statut validee ou abandonnee pour raison autre + non payee + aucun paiement + pas deja remplacee diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 6deb0161c2a..58c7063e40a 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -117,7 +117,7 @@ class HookManager * @param Object &$object Object to use hooks on * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints. + * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. * Can also return some values into an array ->results. * $this->error or this->errors are also defined by class called by this function if error. */ @@ -131,7 +131,7 @@ class HookManager // Define type of hook ('output', 'returnvalue' or 'addreplace'). 'addreplace' should be type for all hooks. 'output' and 'returnvalue' are deprecated. $hooktype='output'; if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win. - if (in_array($method,array('doActions','formObjectOptions','moveUploadedFile','pdf_writelinedesc','paymentsupplierinvoices'))) $hooktype='addreplace'; + if (in_array($method,array('doActions','formObjectOptions','moveUploadedFile','pdf_writelinedesc','paymentsupplierinvoices','printSearchForm'))) $hooktype='addreplace'; // Loop on each hook to qualify modules that declared context $modulealreadyexecuted=array(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6f98c742e82..9093f3be8ee 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -542,8 +542,6 @@ class FormFile { if (empty($noform)) $out.= ''."\n"; } - -$out.='
'; } $out.= ''."\n"; //return ($i?$i:$headershown); diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index fe21a82c56f..65e2df4d088 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -50,20 +50,24 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); -print ''."\n"; -print '

'; +print ''."\n"; +//print '
'; + +$nbofsearch=0; // Define $searchform if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); + $nbofsearch++; } if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); + $nbofsearch++; } if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) @@ -71,6 +75,7 @@ if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! em { $langs->load("products"); $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); + $nbofsearch++; } if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) @@ -78,27 +83,35 @@ if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! em { $langs->load("products"); $searchform.=printSearchForm(DOL_URL_ROOT.'/fourn/product/liste.php', DOL_URL_ROOT.'/fourn/product/liste.php', img_object('','product').' '.$langs->trans("SupplierRef"), 'products', 'srefsupplier'); + $nbofsearch++; } if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire) { $langs->load("members"); $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); + $nbofsearch++; } // Execute hook printSearchForm $parameters=array(); -$searchform.=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('printSearchForm',$parameters); +if (empty($reshook)) $searchform.=$hookmanager->resPrint; +else $searchform=$hookmanager->resPrint; +print ''; print "\n"; print "\n"; -print '
'."\n"; +print '
'; +//print '
'; +print '
'."\n"; print $searchform; print '
'."\n"; +//print '
'; +print '
'; print "\n"; -print '
'; print ''."\n"; $db->close(); diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index bd1c1075e2e..1b81787e88d 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -85,7 +85,7 @@ ProductsAndServicesArea=Espace Produits et Services ProductsArea=Espace Produits ServicesArea=Espace Services AddToMyProposals=Ajouter à mes propositions -AddToOtherProposals=Ajouter aux autres propositions +AddToOtherProposals=Ajouter propositions brouillons AddToMyBills=Ajouter à mes factures AddToOtherBills=Ajouter aux autres factures CorrectStock=Corriger stock diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 5a52f3b442b..0d849a30379 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -53,7 +53,7 @@ PropalsToBill=Propositions commerciales signées à facturer ListOfProposals=Liste des devis/propositions commerciales ActionsOnPropal=Événements sur la proposition NoOpenedPropals=Pas de proposition ouverte -NoOtherOpenedPropals=Pas d'autre proposition ouverte +NoOtherOpenedPropals=Pas d'autre proposition brouillon RefProposal=Réf proposition commerciale SendPropalByMail=Envoi proposition commerciale par mail FileNotUploaded=Le fichier n'a pas été téléchargé diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index d2b81d4ce04..df83afc6b7e 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1316,6 +1316,7 @@ print "\n

\n"; if ($object->id && ($action == '' || $action == 'view') && $object->status) { print ''; + //print '
'; // Propals if (! empty($conf->propal->enabled) && $user->rights->propale->creer) @@ -1324,113 +1325,41 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status) $langs->load("propal"); - print '
'; + print ''; + print ''; + print ''; + print ''; } + print '
'; - print $langs->trans("AddToMyProposals") . '
'.$langs->trans("AddToOtherProposals").'
'; - if ($user->rights->societe->client->voir) + $var=true; + $otherprop = $propal->liste_array(2,1,0); + print '
'; + print ''; + print ''; + if (is_array($otherprop) && count($otherprop)) { - print ''; + $var=!$var; + print ''; + print ''; } else { - print ''; - } - - print ''; - - // Liste de "Mes propals" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - - $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = 0"; - $sql.= " AND p.fk_user_author = ".$user->id; - $sql.= " ORDER BY p.datec DESC, p.tms DESC"; - - $result=$db->query($sql); - if ($result) - { - $var=true; - $num = $db->num_rows($result); - print '
'; - print $langs->trans("AddToOtherProposals").'
'; + print ''; + print $langs->trans("Proposals").''; + print $form->selectarray("propalid", $otherprop, 0, 1); + print '
'.$langs->trans("Quantity").' '; + print ''.$langs->trans("ReductionShort").'(%) '; + print ''; + print ''; + print ''; + print '
 
'; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print '\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print ""; - } - print "
'; - print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - if (isset($object->stock_proposition)) print " ".$object->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedPropals"); - print "
"; - $db->free($result); + print "
"; + print $langs->trans("NoOtherOpenedPropals"); + print '
'; + print ''; print ''; - - if ($user->rights->societe->client->voir) - { - // Liste de "Other propals" - print ''; - - $var=true; - $otherprop = $propal->liste_array(1,1,1); - print '
'; - print ''; - print ''; - if (is_array($otherprop) && count($otherprop)) - { - $var=!$var; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherPropals").''; - print $form->selectarray("propalid", $otherprop); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedPropals"); - print '
'; - print '
'; - - print ''; - } - print ''; } @@ -1441,261 +1370,87 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status) $langs->load("orders"); - print ''; - print $langs->trans("AddToMyOrders").''; + print ''; + print ''.$langs->trans("AddToOtherOrders").''; + print ''; + print ''; - if ($user->rights->societe->client->voir) + $var=true; + $othercom = $commande->liste_array(2, 1, null); + print '
'; + print ''; + print ''; + if (is_array($othercom) && count($othercom)) { - print ''; + $var=!$var; + print ''; + print ''; } else - { - print ''; - } - - print ''; - - // Liste de "Mes commandes" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - - $sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref, c.date_commande as dc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_statut = 0"; - $sql.= " AND c.fk_user_author = ".$user->id; - $sql.= " ORDER BY c.date_creation DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print '
'; - print $langs->trans("AddToOtherOrders").'
'; + print ''; + print $langs->trans("Orders").''; + print $form->selectarray("commandeid", $othercom, 0, 1); + print '
'.$langs->trans("Quantity").' '; + print ''.$langs->trans("ReductionShort").'(%) '; + print ''; + print ''; + print ''; + print '
 
'; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objc = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print '\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
'; - print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($db->jdate($objc->dc),"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - if (isset($object->stock_proposition)) print " ".$object->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedOrders"); - print '
"; - $db->free($result); + { + print ""; + print $langs->trans("NoOtherOpenedOrders"); + print ''; } + print ''; + print ''; print ''; - - if ($user->rights->societe->client->voir) - { - // Liste de "Other orders" - print ''; - - $var=true; - $othercom = $commande->liste_array(1, $user); - print '
'; - print ''; - print ''; - if (is_array($othercom) && count($othercom)) - { - $var=!$var; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherOrders").''; - print $form->selectarray("commandeid", $othercom); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedOrders"); - print '
'; - print '
'; - - print ''; - } - print ''; } // Factures if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { - print ''; - print $langs->trans("AddToMyBills").''; + $invoice = new Facture($db); - if ($user->rights->societe->client->voir) - { - print ''; - print $langs->trans("AddToOtherBills").''; - } - else - { - print ' '; - } + $langs->load("bills"); - print ''; - - // Liste de Mes factures - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 0"; - $sql.= " AND f.fk_user_author = ".$user->id; - $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print "'; - } - print "
"; - print "factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($db->jdate($objp->df),"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoDraftBills"); - print '
"; - $db->free($result); - } - else - { - dol_print_error($db); - } - - print ''; - - if ($user->rights->societe->client->voir) - { - $facture = new Facture($db); - - print ''; - - // Liste de Autres factures - $var=true; - - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 0"; - $sql.= " AND f.fk_user_author <> ".$user->id; - $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print ""; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
factureid."\">$objp->facnumbersocid."\">".dol_trunc($objp->nom,24)."".$langs->trans("Qty"); - print "'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherDraftBills"); - print '
"; - $db->free($result); - } - else - { - dol_print_error($db); - } - - print ''; - } - - print ''; + print ''; + print ''.$langs->trans("AddToOtherOrders").''; + print ''; + print ''; + + $var=true; + $otherinvoice = $invoice->liste_array(2, 1, null); + print '
'; + print ''; + print ''; + if (is_array($otherinvoice) && count($otherinvoice)) + { + $var=!$var; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("Invoice").''; + print $form->selectarray("factureid", $otherinvoice, 0, 1); + print '
'.$langs->trans("Quantity").' '; + print ''.$langs->trans("ReductionShort").'(%) '; + print ''; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherDraftBills"); + print '
'; + print '
'; + + print ''; + print ''; } print '';