diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index a67d2c3ac02..936d269f82a 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2018 Josep LluĂ­s Amador * * 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 @@ -20,7 +21,7 @@ /** * \file htdocs/core/boxes/box_contacts.php - * \ingroup societes + * \ingroup contacts * \brief Module to show box of contacts */ @@ -57,7 +58,7 @@ class box_contacts extends ModeleBoxes $this->db=$db; - $this->hidden=! ($user->rights->societe->lire); + $this->hidden=! ($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** @@ -75,12 +76,12 @@ class box_contacts extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts",$max)); - if ($user->rights->societe->lire) + if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; $sql.= ", s.nom as socname, s.name_alias"; - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -91,98 +92,97 @@ class box_contacts extends ModeleBoxes $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { + if ($result) { $num = $db->num_rows($result); $contactstatic=new Contact($db); $societestatic=new Societe($db); $line = 0; - while ($line < $num) - { + while ($line < $num) + { $objp = $db->fetch_object($result); $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); - $contactstatic->id=$objp->id; + $contactstatic->id=$objp->id; $contactstatic->lastname=$objp->lastname; - $contactstatic->firstname=$objp->firstname; - $contactstatic->civility_id=$objp->civility_id; + $contactstatic->firstname=$objp->firstname; + $contactstatic->civility_id=$objp->civility_id; $contactstatic->statut=$objp->status; - $contactstatic->phone_pro = $objp->phone; - $contactstatic->phone_perso = $objp->phone_perso; - $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->address = $objp->address; - $contactstatic->zip = $objp->zip; - $contactstatic->town = $objp->town; + $contactstatic->phone_pro = $objp->phone; + $contactstatic->phone_perso = $objp->phone_perso; + $contactstatic->phone_mobile = $objp->phone_mobile; + $contactstatic->address = $objp->address; + $contactstatic->zip = $objp->zip; + $contactstatic->town = $objp->town; $societestatic->id = $objp->fk_soc; - $societestatic->name = $objp->socname; - $societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_fournisseur = $objp->code_fournisseur; - $societestatic->client = $objp->client; - $societestatic->fournisseur = $objp->fournisseur; + $societestatic->name = $objp->socname; + $societestatic->name_alias = $objp->name_alias; + $societestatic->code_client = $objp->code_client; + $societestatic->code_fournisseur = $objp->code_fournisseur; + $societestatic->client = $objp->client; + $societestatic->fournisseur = $objp->fournisseur; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $contactstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $contactstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'align="right" class="nowrap" width="18"', - 'text' => $contactstatic->getLibStatut(3), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" class="nowrap" width="18"', + 'text' => $contactstatic->getLibStatut(3), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedContacts"), - ); + if ($num==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedContacts"), + ); - $db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'align="left" class="nohover opacitymedium"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput=0) - { + function showBox($head = null, $contents = null, $nooutput=0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index e44ab8cafd8..2061b03d2ae 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -46,11 +46,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("bank"); - $langs->load("withdrawals"); - $langs->load("companies"); + + // Translations + $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); $this->db = $db; $this->name = "sepamandate"; @@ -104,13 +102,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); - $outputlangs->load("withdrawals"); - $outputlangs->load("bills"); + + // Translations + $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); if (! empty($conf->bank->dir_output)) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b2a0a6faf4f..f90323cda0e 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -320,7 +320,7 @@ class modProduct extends DolibarrModules 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0' ); - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef'); + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); } if (! empty($conf->global->PRODUIT_MULTIPRICES)) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index a064d032083..8d62a4190ca 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -222,4 +222,6 @@ NoAssignedTasks=No assigned tasks (assign project/tasks the current user from th # Comments trans AllowCommentOnTask=Allow user comments on tasks AllowCommentOnProject=Allow user comments on projects - +DontHavePermissionForCloseProject=You do not have permissions to close the project %s +DontHaveTheValidateStatus=The project %s must be open to be closed +RecordsClosed=%s project(s) closed diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 6eebc4d85e2..fd29143613a 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -272,7 +272,7 @@ print '
'; * Last modified products */ $max=15; -$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.fk_price_expression,"; +$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; $sql.= " p.entity,"; $sql.= " p.tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; @@ -336,7 +336,8 @@ if ($result) $product_static->ref=$objp->ref; $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; - $product_static->entity = $objp->entity; + $product_static->entity = $objp->entity; + $product_static->status_batch = $objp->tobatch; print $product_static->getNomUrl(1,'',16); print "\n"; print ''.dol_trunc($objp->label,32).''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 662c15507f0..e31a88e6f5c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -698,6 +698,7 @@ else $product_static->type = $obj->fk_product_type; $product_static->status_buy = $obj->tobuy; $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; $product_static->entity = $obj->entity; $product_static->pmp = $obj->pmp; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index f732c44fc31..1566e5d36c0 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -446,7 +446,7 @@ else $totalunit=0; $totalvalue=$totalvaluesell=0; - $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; $sql.= " ps.reel as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_product = p.rowid"; @@ -487,10 +487,11 @@ else print ''; print ""; $productstatic->id=$objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->label = $objp->produit; + $productstatic->ref = $objp->ref; + $productstatic->label = $objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; print $productstatic->getNomUrl(1,'stock',16); print ''; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index b41a990fbc1..41c8f9ae1f0 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -415,7 +415,7 @@ $formother=new FormOther($db); $formproduct=new FormProduct($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); -$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; +$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; @@ -891,6 +891,7 @@ if ($resql) $productstatic->label=$objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; $productlot->id = $objp->lotid; $productlot->batch= $objp->batch; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e148caeb328..90f0fc56755 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -195,6 +195,52 @@ if (empty($reshook)) $permtodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // Close records + if (! $error && $massaction == 'close' && $user->rights->projet->creer) + { + $db->begin(); + + $objecttmp=new $objectclass($db); + $nbok = 0; + foreach($toselect as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + $userWrite = $object->restrictedProjectArea($user,'write'); + if ($userWrite > 0 && $objecttmp->statut == 1) { + $result = $objecttmp->setClose($user); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } elseif($userWrite <= 0) { + setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); + } else { + setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); + } + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (! $error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + } } @@ -390,7 +436,9 @@ $arrayofmassactions = array( ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print '
';