From a7813c37a1dee3b5ba8d2e4da451e0f16e96f519 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Dec 2016 12:36:00 +0100 Subject: [PATCH 001/172] init inventory integration --- htdocs/core/class/coreobject.class.php | 214 ++++++++++ htdocs/inventory/ajax/ajax.inventory.php | 50 +++ htdocs/inventory/class/inventory.class.php | 466 +++++++++++++++++++++ 3 files changed, 730 insertions(+) create mode 100644 htdocs/core/class/coreobject.class.php create mode 100644 htdocs/inventory/ajax/ajax.inventory.php create mode 100644 htdocs/inventory/class/inventory.class.php diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php new file mode 100644 index 00000000000..1cc68f38cb7 --- /dev/null +++ b/htdocs/core/class/coreobject.class.php @@ -0,0 +1,214 @@ + + * + * 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/core/class/coreobject.inventory.php + * \ingroup core + * \brief File of class to manage all object. Might be replace or merge into commonobject + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + +class CoreObject extends CommonObject { + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct(DoliDB &$db) { + + $this->db = &$db; + + $this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? + } + + private function init() { + + $this->id = 0; + $this->datec = time(); + $this->tms = time(); + + if(!empty($this->__fields)) { + foreach ($this->__fields as $field=>$info) { + + if($this->is_date($info)){ + $this->{$field} = time(); + } + elseif($this->is_array($info)){ + $this->{$field} = array(); + } + elseif($this->is_int($info)){ + $this->{$field} = (int)0; + } + elseif($this->is_float($info)) { + $this->{$field} = (double)0; + } + else{ + $this->{$field} = ''; + } + } + + $this->to_delete=false; + + return true; + } + else{ + return false; + } + + } + + + private function is_date(Array &$info){ + + if(is_array($info)) { + if(isset($info['type']) && $info['type']=='date') return true; + else return false; + } + else return false; + } + + private function is_array($info) { + + if(is_array($info)) { + if(isset($info['type']) && $info['type']=='array') return true; + else return false; + } + else return false; + } + + + private function is_null($info){ + if(is_array($info)) { + if(isset($info['type']) && $info['type']=='null') return true; + else return false; + } + else return false; + } + + private function is_int($info){ + + if(is_array($info)) { + if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true; + else return false; + } + else return false; + } + private function _is_float($info){ + if(is_array($info)) { + if(isset($info['type']) && $info['type']=='float') return true; + else return false; + } else return false; + } + + private function _is_text($info){ + if(is_array($info)) { + if(isset($info['type']) && $info['type']=='text') return true; + else return false; + } else return false; + } + private function _is_index($info){ + if(is_array($info)) { + if(isset($info['index']) && $info['index']==true) return true; + else return false; + } else return false; + } + + private function set_save_query(){ + + $query=array( + 'rowid'=>$this->id + ,'datec'=>($this->id>0 ? $this->db->jdate($this->datec) : time()) + ,'tms'=>time() + ); + + foreach ($this->__fields as $field=>$info) { + + if($this->_is_date($info)){ + if(empty($this->{$field})){ + $query[$field] = $this->date_0; + } + else{ + $query[$field] = $this->db->jdate($this->{$field}); + } + } + else if($this->is_array($info)){ + $query[$field] = serialize($this->{$field}); + } + + else if($this->is_int($info)){ + $query[$field] = (int)price2num($this->{$field}); + } + + else if($this->_is_float($info)){ + $query[$field] = (double)price2num($this->{$field}); + } + + elseif($this->_is_null($info)) { + $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0')?null:$this->{$field}); + } + else{ + $query[$field] = $this->{$field}; + } + + } + + return $query; + } + + + public function fetch($id, $loadChild = true) { + + if(empty($id)) return false; + + $res = $db->query( 'SELECT '.$this->get_field_list().'datec,tms + FROM '.$this->table_element.' + WHERE rowid='.$id ); + if($obj = $db->fetch_object($res)) { + $this->rowid=$id; + + $this->set_vars_by_db($db); + + $this->datec=$this->db->idate($obj->datec); + $this->tms=$this->db->idate($obj->tms); + + if($loadChild) $this->loadChild($db); + + $this->run_trigger($db, 'load'); + + return $this->id; + } + else { + return false; + } + + } + public function update() { + + + + } + public function create() { + + + + } + + +} diff --git a/htdocs/inventory/ajax/ajax.inventory.php b/htdocs/inventory/ajax/ajax.inventory.php new file mode 100644 index 00000000000..34efecfab8f --- /dev/null +++ b/htdocs/inventory/ajax/ajax.inventory.php @@ -0,0 +1,50 @@ +rights->inventory->write) { echo -1; exit; } + + $fk_det_inventory = GETPOST('fk_det_inventory'); + + $det = new Inventorydet; + if( $det->load($PDOdb, $fk_det_inventory)) { + $det->qty_view+=GETPOST('qty'); + $det->save($PDOdb); + + echo $det->qty_view; + } + else { + echo -2; + } + + break; + + case 'pmp': + if (!$user->rights->inventory->write || !$user->rights->inventory->changePMP) { echo -1; exit; } + + $fk_det_inventory = GETPOST('fk_det_inventory'); + + $det = new Inventorydet; + if( $det->load($PDOdb, $fk_det_inventory)) { + $det->new_pmp=price2num(GETPOST('pmp')); + $det->save($PDOdb); + + echo $det->new_pmp; + } + else { + echo -2; + } + + break; + + } + diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php new file mode 100644 index 00000000000..808dd7933be --- /dev/null +++ b/htdocs/inventory/class/inventory.class.php @@ -0,0 +1,466 @@ + + * + * 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/inventory/class/product.inventory.php + * \ingroup product + * \brief File of class to manage predefined products stock + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/coreobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + +class Inventory extends CoreObject +{ + + public $element='inventory'; + public $table_element='inventory'; + public $fk_element='fk_inventory'; + protected $childtables=array('inventorydet'); // To test if we can delete object + protected $isnolinkedbythird = 1; // No field fk_soc + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + /** + * Warehouse Id + * @var int + */ + public $fk_warehouse; + /** + * Entity Id + * @var int + */ + public $entity; + + /** + * Status + * @var int + */ + public $status; + /** + * Inventory Date + * @var date + */ + public $date_inventory; + /** + * Inventory Title + * @var string + */ + public $title; + + private $__fields=array( + 'fk_warehouse'=>array('type'=>'integer','index'=>true) + ,'entity'=>array('type'=>'integer','index'=>true) + ,'status'=>array('type'=>'integer','index'=>true) + ,'date_inventory'=>array('type'=>'date') + ,'title'=>array('type'=>'string') + ); + + function __construct() + { + + parent::init(); + + $this->_init_vars(); + + $this->start(); + + $this->setChild('Inventorydet','fk_inventory'); + + $this->status = 0; + $this->entity = $conf->entity; + $this->errors = array(); + $this->amount = 0; + + } + + function sort_det() + { + usort($this->Inventorydet, array('Inventory', 'customSort')); + } + + function load(&$PDOdb, $id,$annexe = true) + { + + if(!$annexe) $this->withChild = false; + + $res = parent::load($PDOdb, $id); + $this->sort_det(); + + $this->amount = 0; + foreach($this->Inventorydet as &$det){ + $this->amount+=$det->qty_view * $det->pmp; + } + + return $res; + } + + + function customSort(&$objA, &$objB) + { + global $db; + + $r = strcmp(strtoupper(trim($objA->product->ref)), strtoupper(trim($objB->product->ref))); + + if ($r < 0) $r = -1; + elseif ($r > 0) $r = 1; + else $r = 0; + + return $r; + } + + function changePMP(&$PDOdb) { + + foreach ($this->Inventorydet as $k => &$Inventorydet) + { + + if($Inventorydet->new_pmp>0) { + $Inventorydet->pmp = $Inventorydet->new_pmp; + $Inventorydet->new_pmp = 0; + + $PDOdb->Execute("UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$Inventorydet->pmp." + WHERE rowid = ".$Inventorydet->fk_product ); + + if((float)DOL_VERSION<4.0) { + + $PDOdb->Execute("UPDATE ".MAIN_DB_PREFIX."product_stock SET pmp=".$Inventorydet->pmp." + WHERE fk_entrepot = ".$this->fk_warehouse." AND fk_product = ".$Inventorydet->fk_product) ; + + } + + } + } + + parent::save($PDOdb); + + } + + function save(&$PDOdb) + { + //si on valide l'inventaire on sauvegarde le stock à cette instant + if ($this->status) + { + $this->regulate($PDOdb); + } + + parent::save($PDOdb); + } + + function set_values($Tab) + { + global $db,$langs; + + if (isset($Tab['qty_to_add'])) + { + foreach ($Tab['qty_to_add'] as $k => $qty) + { + $qty = (float) price2num($qty); + + if ($qty < 0) + { + $this->errors[] = $langs->trans('inventoryErrorQtyAdd'); + return 0; + } + + $product = new Product($db); + $product->fetch($this->Inventorydet[$k]->fk_product); + + $this->Inventorydet[$k]->pmp = $product->pmp; + $this->Inventorydet[$k]->qty_view += $qty; + } + } + + return parent::set_values($Tab); + } + + function deleteAllLine(&$PDOdb) { + + foreach($this->Inventorydet as &$det) { + $det->to_delete = true; + } + + $this->save($PDOdb); + + $this->Inventorydet=array(); + + } + + function add_product(&$PDOdb, $fk_product, $fk_entrepot='') { + + $k = $this->addChild($PDOdb, 'Inventorydet'); + $det = &$this->Inventorydet[$k]; + + $det->fk_inventory = $this->getId(); + $det->fk_product = $fk_product; + $det->fk_warehouse = empty($fk_entrepot) ? $this->fk_warehouse : $fk_entrepot; + + $det->load_product(); + + $date = $this->get_date('date_inventory', 'Y-m-d'); + if(empty($date))$date = $this->get_date('date_cre', 'Y-m-d'); + $det->setStockDate($PDOdb, $date , $fk_entrepot); + + } + + function correct_stock($fk_product, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $inventorycode='') + { + global $conf, $db, $langs, $user; + + /* duplication method product to add datem */ + if ($id_entrepot) + { + $db->begin(); + + require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + + $op[0] = "+".trim($nbpiece); + $op[1] = "-".trim($nbpiece); + + $datem = empty($conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT) ? dol_now() : $this->date_inventory; + + $movementstock=new MouvementStock($db); + $result=$movementstock->_create($user,$fk_product,$id_entrepot,$op[$movement],$movement,$price,$label,$inventorycode, $datem); + + if ($result >= 0) + { + $db->commit(); + return 1; + } + else + { + $this->error=$movementstock->error; + $this->errors=$movementstock->errors; + + $db->rollback(); + return -1; + } + } + } + + function regulate(&$PDOdb) + { + global $db,$user,$langs,$conf; + + if($conf->global->INVENTORY_DISABLE_VIRTUAL){ + $pdt_virtuel = false; + // Test si pdt virtuel est activé + if($conf->global->PRODUIT_SOUSPRODUITS) + { + $pdt_virtuel = true; + $conf->global->PRODUIT_SOUSPRODUITS = 0; + } + } + + foreach ($this->Inventorydet as $k => $Inventorydet) + { + $product = new Product($db); + $product->fetch($Inventorydet->fk_product); + + /* + * Ancien code qui était pourri et qui modifié la valeur du stock théorique si le parent était déstocké le même jour que l'enfant + * + * $product->load_stock(); + $Inventorydet->qty_stock = $product->stock_warehouse[$this->fk_warehouse]->real; + + if(date('Y-m-d', $this->date_inventory) < date('Y-m-d')) { + $TRes = $Inventorydet->getPmpStockFromDate($PDOdb, date('Y-m-d', $this->date_inventory), $this->fk_warehouse); + $Inventorydet->qty_stock = $TRes[1]; + } + */ + if ($Inventorydet->qty_view != $Inventorydet->qty_stock) + { + $Inventorydet->qty_regulated = $Inventorydet->qty_view - $Inventorydet->qty_stock; + $nbpiece = abs($Inventorydet->qty_regulated); + $movement = (int) ($Inventorydet->qty_view < $Inventorydet->qty_stock); // 0 = add ; 1 = remove + + $href = dol_buildpath('/inventory/inventory.php?id='.$this->getId().'&action=view', 1); + + if(empty($this->title)) + $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock', $href, $this->getId())); + else + $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStockWithNomInventaire', $href, $this->title)); + } + } + + if($conf->global->INVENTORY_DISABLE_VIRTUAL){ + // Test si pdt virtuel était activé avant la régule + if($pdt_virtuel) $conf->global->PRODUIT_SOUSPRODUITS = 1; + } + + return 1; + } + + static function getLink($id) { + global $langs; + + $PDOdb=new TPDOdb; + + $i = new Inventory; + $i->load($PDOdb, $id, false); + + $title = !empty($i->title) ? $i->title : $langs->trans('inventoryTitle').' '.$i->getId(); + + return ''.img_picto('','object_list.png','',0).' '.$title.''; + + } +} + +class Inventorydet extends TObjetStd +{ + function __construct() + { + global $conf; + + $this->set_table(MAIN_DB_PREFIX.'inventorydet'); + $this->TChamps = array(); + $this->add_champs('fk_inventory,fk_warehouse,fk_product,entity', 'type=entier;'); + $this->add_champs('qty_view,qty_stock,qty_regulated,pmp,pa,new_pmp', 'type=float;'); + + $this->_init_vars(); + $this->start(); + + $this->entity = $conf->entity; + $this->errors = array(); + + $this->product = null; + + $this->current_pa = 0; + + } + + function load(&$PDOdb, $id) + { + global $conf; + + $res = parent::load($PDOdb, $id); + $this->load_product(); + $this->fetch_current_pa(); + + return $res; + } + + function fetch_current_pa() { + global $db,$conf; + + if(empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) return false; + + if($this->pa>0){ + $this->current_pa = $this->pa; + } + else { + + dol_include_once('/fourn/class/fournisseur.product.class.php'); + $p= new ProductFournisseur($db); + $p->find_min_price_product_fournisseur($this->fk_product); + + if($p->fourn_qty>0) $this->current_pa = $p->fourn_price / $p->fourn_qty; + } + return true; + } + + function setStockDate(&$PDOdb, $date, $fk_warehouse) { + + list($pmp,$stock) = $this->getPmpStockFromDate($PDOdb, $date, $fk_warehouse); + + $this->qty_stock = $stock; + $this->pmp = $pmp; + + $last_pa = 0; + $sql = "SELECT price FROM ".MAIN_DB_PREFIX."stock_mouvement + WHERE fk_entrepot=".$fk_warehouse." + AND fk_product=".$this->fk_product." + AND (origintype='order_supplier' || origintype='invoice_supplier') + AND price>0 + AND datem<='".$date." 23:59:59' + ORDER BY datem DESC LIMIT 1"; + + $PDOdb->Execute($sql); + + if($obj = $PDOdb->Get_line()) { + $last_pa = $obj->price; + } + + $this->pa = $last_pa; + /* var_dump($fk_warehouse,$this->product->stock_warehouse,$this->pmp, $this->pa, $this->qty_stock); + exit;*/ + } + + function getPmpStockFromDate(&$PDOdb, $date, $fk_warehouse){ + + $res = $this->product->load_stock(); + + if($res>0) { + $stock = isset($this->product->stock_warehouse[$fk_warehouse]->real) ? $this->product->stock_warehouse[$fk_warehouse]->real : 0; + + if((float)DOL_VERSION<4.0) { + $pmp = isset($this->product->stock_warehouse[$fk_warehouse]->pmp) ? $this->product->stock_warehouse[$fk_warehouse]->pmp : 0; + } + else{ + $pmp = $this->product->pmp; + } + + } + + //On récupère tous les mouvements de stocks du produit entre aujourd'hui et la date de l'inventaire + $sql = "SELECT value, price + FROM ".MAIN_DB_PREFIX."stock_mouvement + WHERE fk_product = ".$this->product->id." + AND fk_entrepot = ".$fk_warehouse." + AND datem > '".date('Y-m-d 23:59:59',strtotime($date))."' + ORDER BY datem DESC"; + + //echo $sql.'
'; + $PDOdb->Execute($sql); + $TMouvementStock = $PDOdb->Get_All(); + $laststock = $stock; + $lastpmp = $pmp; + //Pour chacun des mouvements on recalcule le PMP et le stock physique + foreach($TMouvementStock as $mouvement){ + + //150 + //if($this->product->id==394) echo 'laststock = '.$stock.'
'; + + //9.33 + //if($this->product->id==394) echo 'lastpmp = '.$pmp.'
'; + $price = ($mouvement->price>0 && $mouvement->value>0) ? $mouvement->price : $lastpmp; + + $stock_value = $laststock * $lastpmp; + + $laststock -= $mouvement->value; + + $last_stock_value = $stock_value - ($mouvement->value * $price); + + $lastpmp = ($laststock != 0) ? $last_stock_value / $laststock : $lastpmp; + + + + } + + return array($lastpmp,$laststock); + } + + function load_product() + { + global $db; + + if($this->fk_product>0) { + $this->product = new Product($db); + $this->product->fetch($this->fk_product); + } + + } + +} From cdfbed5d084215994320f82bd98315373e018034 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Dec 2016 17:36:22 +0100 Subject: [PATCH 002/172] new listview --- htdocs/core/class/class.listview.php | 1216 ++++++++++++++++++++ htdocs/inventory/class/inventory.class.php | 64 +- 2 files changed, 1270 insertions(+), 10 deletions(-) create mode 100644 htdocs/core/class/class.listview.php diff --git a/htdocs/core/class/class.listview.php b/htdocs/core/class/class.listview.php new file mode 100644 index 00000000000..f37fc9a1628 --- /dev/null +++ b/htdocs/core/class/class.listview.php @@ -0,0 +1,1216 @@ + + + This program and all files within this directory and sub directory + 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 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 . + */ + +class Listview { + + function __construct( $id ) { + + $this->id = $id; + + $this->TTotalTmp=array(); + + $this->sql = ''; + + } + private function init(&$TParam) { + + global $conf, $langs; + + if(!isset($TParam['hide']))$TParam['hide']=array(); + if(!isset($TParam['link']))$TParam['link']=array(); + if(!isset($TParam['type']))$TParam['type']=array(); + if(!isset($TParam['orderby']['noOrder']))$TParam['orderby']['noOrder']=array(); + if(!isset($TParam['no-select'])) $TParam['no-select'] = 1; + + if(!isset($TParam['liste']))$TParam['liste']=array(); + $TParam['liste'] = array_merge(array( + 'messageNothing'=>"Il n'y a aucun élément à afficher." + ,'picto_precedent'=>'<' + ,'picto_suivant'=>'>' + ,'order_down'=>img_down() + ,'order_up'=>img_up() + ,'noheader'=>0 + ,'useBottomPagination'=>0 + ,'image'=>'' + ,'titre'=>'Liste' + ,'orderDown'=>'' + ,'orderUp'=>'' + ,'id'=>$this->id + ,'picto_search'=>img_picto('Search', 'search.png') + ,'head_search'=>'' + ,'export'=>array() + ,'view_type'=>'' + ),$TParam['liste']); + + if(empty($TParam['limit']))$TParam['limit']=array(); + if(!empty($_REQUEST['TListTBS'][$this->id]['page'])) $TParam['limit']['page'] = $_REQUEST['TListTBS'][$this->id]['page']; + + $TParam['limit']=array_merge(array('page'=>1, 'nbLine'=>$conf->liste_limit, 'global'=>0), $TParam['limit']); + + if(!empty($_REQUEST['TListTBS'][$this->id]['orderBy'])) { + $TParam['orderBy'] = $_REQUEST['TListTBS'][$this->id]['orderBy']; + } + + // print_r($TParam); + } + private function getSearchNull($key, &$TParam) { + return !empty($TParam['search'][$key]['allow_is_null']); + } + private function getSearchKey($key, &$TParam) { + + $TPrefixe=array(); + if(!empty($TParam['search'][$key]['table'])) { + if (!is_array($TParam['search'][$key]['table'])) $TParam['search'][$key]['table'] = array($TParam['search'][$key]['table']); + + foreach ($TParam['search'][$key]['table'] as $prefix_table) { + $TPrefixe[] = '`'.$prefix_table.'`.'; + } + } + + $TKey=array(); + if(!empty($TParam['search'][$key]['field'])) { + if (!is_array($TParam['search'][$key]['field'])) $TParam['search'][$key]['field'] = array($TParam['search'][$key]['field']); + + foreach ($TParam['search'][$key]['field'] as $i => $field) { + $prefixe = !empty($TPrefixe[$i]) ? $TPrefixe[$i] : $TPrefixe[0]; + $TKey[] = $prefixe.'`'. $field .'`'; + } + } else { + $TKey[] =$TPrefixe[0].'`'. strtr($key,';','*').'`'; + } + + return $TKey; + } + private function getSearchValue($value) { + $value = strtr(trim($value),';','*'); + + return $value; + } + + private function dateToSQLDate($date) { + + list($dd,$mm,$aaaa) = explode('/', substr($date,0,10)); + + $value = date('Y-m-d', mktime(0,0,0,$mm,$dd,$aaaa)); + + return $value; + } + + private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey, $sBindKey) + { + if(is_array($value)) + { + + unset($this->TBind[$sBindKey]); + // Si le type de "recherche" est "calendars" on a 2 champs de transmis, [début et fin] ou [que début] ou [que fin] => un BETWEEN Sql serait utile que dans le 1er cas + // donc l'utilisation des opérateur >= et <= permettent un fonctionnement générique + $TSQLDate=array(); + if(!empty($value['deb'])) + { + $valueDeb = $this->dateToSQLDate($value['deb']); + + if(isset($this->TBind[$sBindKey.'_start'])) // TODO can't use this in query case + { + $this->TBind[$sBindKey.'_start'] = $valueDeb; + } + + $TSQLDate[]=$sKey." >= '".$valueDeb." 00:00:00'" ; + + } + + if(!empty($value['fin'])) + { + $valueFin = $this->dateToSQLDate($value['fin']); + if(isset($this->TBind[$sBindKey.'_end'])) { // TODO can't use this in query case + $this->TBind[$sBindKey.'_end'] = $valueFin; + } + + $TSQLDate[]=$sKey." <= '".$valueFin." 23:59:59'" ; + + } + + if(!empty($TSQLDate)) $TSQLMore[] = implode(' AND ', $TSQLDate); + } + else + { + // Sinon je communique une date directement au format d/m/Y et la méthode du dessous reformat en Y-m-d + $value = $this->dateToSQLDate($value); + if(isset($this->TBind[$sBindKey])) + { + $this->TBind[$sBindKey] = $value; + } + else + { + // Le % en fin de chaine permet de trouver un resultat si le contenu est au format Y-m-d H:i:s et non en Y-m-d + $TSQLMore[]=$sKey." LIKE '".$value."%'" ; + } + } + } + + private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $sBindKey, $key) + { + + $value = $this->getSearchValue($value); + + if(isset($TParam['operator'][$key])) + { + if($TParam['operator'][$key] == '<' || $TParam['operator'][$key] == '>' || $TParam['operator'][$key]=='=') + { + $TSQLMore[] = $sKey . ' ' . $TParam['operator'][$key] . ' "' . $value . '"'; + } + elseif ($TParam['operator'][$key]=='IN') + { + $TSQLMore[] = $sKey . ' ' . $TParam['operator'][$key] . ' (' . $value . ')'; + } + else + { + if(strpos($value,'%')===false) $value = '%'.$value.'%'; + $TSQLMore[]=$sKey." LIKE '".addslashes($value)."'" ; + } + } + else + { + if(strpos($value,'%')===false) $value = '%'.$value.'%'; + $TSQLMore[]=$sKey." LIKE '".addslashes($value)."'" ; + } + + + } + + private function search($sql,&$TParam) { + + if(!empty($_REQUEST['TListTBS'][$this->id]['search'])) { + $sqlGROUPBY=''; + if(strpos($sql,'GROUP BY')!==false) { //TODO regex + list($sql, $sqlGROUPBY) = explode('GROUP BY', $sql); + } + + if(strpos($sql,'WHERE ')===false)$sql.=' WHERE 1 '; //TODO regex + + foreach($_REQUEST['TListTBS'][$this->id]['search'] as $key=>$value) + { + $TsKey = $this->getSearchKey($key, $TParam); + $TsBindKey = $this->getTsBindKey($TsKey); + + //if (!empty($value)) var_dump($TsKey, $TsBindKey, '=================================='); + $TSQLMore = array(); + + $allow_is_null = $this->getSearchNull($key,$TParam); + $search_on_null = false; //TODO useless + + foreach ($TsKey as $i => &$sKey) + { + //if (!empty($value)) var_dump($sKey); + $sBindKey = $TsBindKey[$i]; + + if($allow_is_null && !empty($_REQUEST['TListTBS'][$this->id]['search_on_null'][$key])) + { + $this->TBind[$sBindKey.'_null'] = $sKey.' IS NULL '; + $TSQLMore[] = $sKey.' IS NULL '; + $search_on_null = true; + + if(isset($this->TBind[$sBindKey])) $this->TBind[$sBindKey]= ''; + $value = ''; + } + elseif($allow_is_null) + { + $this->TBind[$sBindKey.'_null'] =0; // $sKey.' IS NOT NULL '; + //$TSQLMore[] = $sKey.' IS NOT NULL '; + } + + if($value!='') { // pas empty car biensûr le statut = 0 existe dans de nombreux cas + + if(isset($TParam['type'][$key]) && ($TParam['type'][$key]==='date' || $TParam['type'][$key]==='datetime')) + { + $this->addSqlFromTypeDate($TSQLMore, $value, $sKey, $sBindKey); + } + else + { + $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $sBindKey, $key); + } + } + } + + if(!isset($this->TBind[$sBindKey]) && !empty($TSQLMore)) + { + $sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) '; + } + + } + + if($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY; + + } + + + return $sql; + } + + private function getViewType(&$TParam) { + if(!empty($TParam['view_type'])) return $TParam['view_type']; + else if (is_string($TParam['type']))return $TParam['type'] ; + else return 'list'; + } + + public function render(&$db,$sql,$TParam=array(),$TBind=array()) { + $this->typeRender = 'sql'; + // print_r($TParam); + $TEntete=array(); + $TChamps=array(); + + $this->init($TParam); + + if(!empty($TBind)) $this->TBind = $TBind; + + $sql = $this->search($sql,$TParam); + $sql = $this->order_by($sql, $TParam); + + $this->parse_sql($db, $TEntete, $TChamps, $TParam, $sql); + + list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + + $view_type = $this->getViewType($TParam); + + if($view_type == 'raw') { + return $this->renderRAW($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); + } + else if($view_type == 'chart') { + return $this->renderChart($TEntete, $TChamps,$TTotal, $TParam); + } + else { + return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); + } + + + } + public function renderDataTableAjax(&$db,$sql,$TParam=array()) { + $this->renderDataTableSQL($db, $sql, $TParam); + } + public function renderDataTableSQL(&$db,$sql,$TParam=array()) { + $this->typeRender = 'dataTableAjax'; + // print_r($TParam); + $TEntete=array(); + $TChamps=array(); + + $this->init($TParam); + + $sql = $this->search($sql,$TParam); + $sql = $this->order_by($sql, $TParam); + + $this->parse_sql($db, $TEntete, $TChamps, $TParam, $sql); + list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + + return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); + + } + public function renderXML(&$db,$xmlString, $TParam=array()) { + $this->typeRender = 'xml'; + + $TEntete=array(); + $TChamps=array(); + + $this->init($TParam); + + $this->parse_xml($db, $TEntete, $TChamps, $TParam,$xmlString); + + list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + + return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); + + } + private function setSearch(&$TEntete, &$TParam) { + global $langs; + + if(empty($TParam['search'])) return array(); + + $TSearch=array(); + $form=new TFormCore; + $form->strict_string_compare = true; + + $nb_search_in_bar = 0; + + if(!empty($TParam['search'])) { + foreach($TEntete as $key=>$libelle) { // init + if(empty($TSearch[$key]))$TSearch[$key]=''; + } + } + foreach($TParam['search'] as $key=>$param_search) { + + + $value = isset($_REQUEST['TListTBS'][$this->id]['search'][$key]) ? $_REQUEST['TListTBS'][$this->id]['search'][$key] : ''; + + $typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search; + + if(is_array($typeRecherche)) { + $typeRecherche = array(''=>' ') + $typeRecherche; + $fsearch=$form->combo('','TListTBS['.$this->id.'][search]['.$key.']', $typeRecherche,$value,0,'',' listviewtbs="combo" init-value="'.$value.'" '); + } + else if($typeRecherche==='calendar') { + $fsearch=$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); + } + else if($typeRecherche==='calendars') { + $fsearch=$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.'][deb]',isset($value['deb'])?$value['deb']:'',10,10,' listviewtbs="calendars" ') + .' '.$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.'][fin]',isset($value['fin'])?$value['fin']:'',10,10,' listviewtbs="calendars" '); + } + else if(is_string($typeRecherche)) { + $fsearch=$TParam['search'][$key]; + } + else { + $fsearch=$form->texte('','TListTBS['.$this->id.'][search]['.$key.']',$value,15,255,' listviewtbs="input" '); + } + + if(!empty($param_search['allow_is_null'])) { + $valueNull = isset($_REQUEST['TListTBS'][$this->id]['search_on_null'][$key]) ? 1 : 0; + $fsearch.=' '.$form->checkbox1('', 'TListTBS['.$this->id.'][search_on_null]['.$key.']',1, $valueNull,' onclick=" if($(this).is(\':checked\')){ $(this).prev().val(\'\'); }" ').img_help(1, $langs->trans('SearchOnNUllValue')); + } + + + if(!empty($TEntete[$key]) || $this->getViewType($TParam) == 'chart') { + $TSearch[$key] = $fsearch; + $nb_search_in_bar++; + } + else { + + $libelle = !empty($TParam['title'][$key]) ? $TParam['title'][$key] : $key ; + $TParam['liste']['head_search'].='
'.$libelle.' '.$fsearch.'
'; + } + + } + + $search_button = ' '.$TParam['liste']['picto_search'].''; + + if(!empty($TParam['liste']['head_search'])) { + $TParam['liste']['head_search'].='
'.$langs->trans('Search').' '.$search_button.'
'; + } + + if($nb_search_in_bar>0) { + end($TSearch); + list($key,$v) = each($TSearch); + $TSearch[$key].=$search_button; + } + else{ + $TSearch=array(); + } + + return $TSearch; + } + + /* + * Function analysant et totalisant une colonne + * Supporté : sum, average + */ + private function get_total(&$TChamps, &$TParam) { + $TTotal=$TTotalGroup=array(); + + if(!empty($TParam['math']) && !empty($TChamps[0])) { + + foreach($TChamps[0] as $field=>$value) { + $TTotal[$field]=''; + $TTotalGroup[$field] = ''; + } + + foreach($TParam['math'] as $field=>$typeMath){ + + if(is_array($typeMath)) { + $targetField = $typeMath[1]; + $typeMath = $typeMath[0]; + } + else { + $targetField = $field; + } + + if($typeMath == 'groupsum') { + $TTotalGroup[$field] = array('target'=>$targetField, 'values'=> $this->TTotalTmp['@groupsum'][$targetField]); + + } + else if($typeMath=='average') { + $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]) / count($this->TTotalTmp[$targetField]); + } + elseif($typeMath=='count') { + $TTotal[$field]=count($this->TTotalTmp[$targetField]); + } + else { + $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]); + } + + } + + + } + + return array($TTotal,$TTotalGroup); + } + + private function getJS(&$TParam) { + $javaScript = ''; + + + if($this->typeRender=='dataTable') { + + $javaScript.=' + '; + + $TPagination=array(); + } + elseif($this->typeRender=='dataTableAjax') { + $javaScript.=' + '; + } + + return $javaScript; + } + + private function setExport(&$TParam,$TChamps,$TEntete) { + global $langs; + + $Tab=array(); + if(!empty($TParam['export'])) { + $token = GETPOST('token'); + if(empty($token)) $token = md5($this->id.time().rand(1,9999)); + + $_SESSION['token_list_'.$token] = gzdeflate( serialize( array( + 'title'=>$this->title + ,'sql'=>$this->sql + ,'TBind'=>$this->TBind + ,'TChamps'=>$TChamps + ,'TEntete'=>$TEntete + ) ) ); + + foreach($TParam['export'] as $mode_export) { + + $Tab[] = array( + 'label'=>$langs->trans('Export'.$mode_export) + ,'url'=>dol_buildpath('/abricot/downlist.php',1) + ,'mode'=>$mode_export + ,'token'=>$token + ,'session_name'=>session_name() + ); + + } + + } + + + return $Tab; + } + + private function renderChart(&$TEntete, &$TChamps,&$TTotal, &$TParam) { + + $TData = array(); + $header = ''; + $first = true; + + $TSearch = $this->setSearch($TEntete, $TParam); + $TExport= $this->setExport($TParam, $TChamps, $TEntete); + + if(empty($TParam['xaxis']) && !empty($TEntete)) { + $fieldXaxis = key($TEntete); + } + else { + $fieldXaxis = $TParam['xaxis']; + } + + $TValue=array(); $key = null; + foreach($TEntete as $field=>&$entete) { + if($field!=$fieldXaxis)$TValue[] = addslashes($entete['libelle']); + } + + $header='["'.addslashes( $TEntete[$fieldXaxis]['libelle'] ).'","'.implode('","', $TValue).'"]'; + //var_dump($fieldXaxis, $TChamps); + foreach($TChamps as &$row) { + $TValue=array(); + $key = null; + + foreach($row as $k=>$v) { + + if($k == $fieldXaxis) { + $key = $v; + } + else { + $TValue[] = (float)$v; + } + + } + + if(!is_null($key)) { + if(!isset($TData[$key])) $TData[$key] = $TValue; + else { + foreach($TData[$key] as $k=>$v) { + $TData[$key][$k]+=(float)$TValue[$k]; + } + + } + } + + + } + + $data = $header; + foreach($TData as $key=>$TValue) { + + $data .= ',[ "'.$key.'", '; + foreach($TValue as $v) { + $data.=(float)$v.','; + } + + $data.=' ]'; + } + + $height = empty($TParam['height']) ? 500 : $TParam['height']; + $curveType= empty($TParam['curveType']) ? 'none': $TParam['curveType']; // none or function + $pieHole = empty($TParam['pieHole']) ? 0: $TParam['pieHole']; // none or function + $hAxis = empty($TParam['hAxis']) ? array() : $TParam['hAxis']; // Array of params + $vAxis = empty($TParam['vAxis']) ? array() : $TParam['vAxis']; // Array of params + + // This feature is experimental and may change in future releases + $explorer = empty($TParam['explorer']) ? array() : $TParam['explorer']; // Note: The explorer only works with continuous axes (such as numbers or dates) + + $type = empty($TParam['chartType']) ? 'LineChart' : $TParam['chartType']; + + $html = ''; + + if(!empty($TSearch)) { + + $html.=''; + foreach($TSearch as $field=>$input) { + if(!empty($input)) { + $label = !empty($TParam['title'][$field]) ? $TParam['title'][$field] : $field; + $html.=''; + } + } + + $html.=''; + + } + $javaScript = $this->getJS($TParam); + + $html.=' + +
+ '.$javaScript; + + return $html; + } + + private function addTotalGroup($TChamps,$TTotalGroup) { + global $langs; + + $Tab=array(); + + $proto_total_line = array(); + + $tagbase = $old_tagbase = null; + + $addGroupLine = false; + + foreach($TChamps as $k=>&$line) { + + if(empty($proto_total_line)) { + foreach($line as $field=>$value) { + $proto_total_line[$field] = ''; + } + $group_line = $proto_total_line; + } + + $addGroupLine = false; + + $tagbase = ''; + foreach($line as $field=>$value) { + + if(!empty($TTotalGroup[$field])) { + $tagbase.=$value.'|'; + $group_line[$field] = '
'.(empty($value) ? $langs->trans('Empty') : $value ).' :
'; + $group_line[$TTotalGroup[$field]['target']] = '
'.price($TTotalGroup[$field]['values'][$value]).'
'; + $addGroupLine = true; + } + + } + + if(!is_null($old_tagbase) && $old_tagbase!=$tagbase && $addGroupLine) { + // var_dump(array($k,$tagbase,$old_tagbase,$empty_line)); + $Tab[] = $previous_group_line; + } + + $old_tagbase = $tagbase; + $previous_group_line = $group_line; + $group_line = $proto_total_line; + + $Tab[] = $line; + + + + } + if($addGroupLine) { + $Tab[] = $previous_group_line; + } + + + return $Tab; + } + + private function renderRAW(&$TEntete, &$TChamps, &$TTotal,&$TTotalGroup, &$TParam) { + $TSearch = $this->setSearch($TEntete, $TParam); + $TExport=$this->setExport($TParam, $TChamps, $TEntete); + $TChamps = $this->addTotalGroup($TChamps,$TTotalGroup); + + return array( + 'entete'=>$TEntete + ,'champs'=>$TChamps + ,'recherche'=>$TSearch + ,'total'=>$TTotal + ,'export'=>$TExport + ,'haveExport'=>count($TExport) + , 'id'=>$this->id + , 'nb_columns'=>count($TEntete) + ,'totalNB'=>count($TChamps) + , 'nbSearch'=>count($TSearch) + , 'haveTotal'=>(int)!empty($TTotal) + , 'havePage'=>(int)!empty($TPagination) + ); + } + + private function renderList(&$TEntete, &$TChamps, &$TTotal,&$TTotalGroup, &$TParam) { + $TBS = new TTemplateTBS; + + $javaScript = $this->getJS($TParam); + + if($this->typeRender!='dataTableAjax') { + $TPagination=array( + 'pagination'=>array('pageSize'=>$TParam['limit']['nbLine'], 'pageNum'=>$TParam['limit']['page'], 'blockName'=>'champs', 'totalNB'=>count($TChamps)) + ); + } + else { + $TPagination=array(); + } + + $TSearch = $this->setSearch($TEntete, $TParam); + $TExport=$this->setExport($TParam, $TChamps, $TEntete); + $TChamps = $this->addTotalGroup($TChamps,$TTotalGroup); + + return $TBS->render($this->template + , array( + 'entete'=>$TEntete + ,'champs'=>$TChamps + ,'recherche'=>$TSearch + ,'total'=>$TTotal + ,'export'=>$TExport + ) + , array( + 'liste'=>array_merge(array('haveExport'=>count($TExport), 'id'=>$this->id, 'nb_columns'=>count($TEntete) ,'totalNB'=>count($TChamps), 'nbSearch'=>count($TSearch), 'haveTotal'=>(int)!empty($TTotal), 'havePage'=>(int)!empty($TPagination) ), $TParam['liste']) + ) + , $TPagination + , array() + ) + .$javaScript; + } + public function renderDatatable(&$db, $TField, $TParam) { + $this->typeRender = 'dataTable'; + // on conserve db pour le traitement ultérieur des subQuery + $TEntete=array(); + $TChamps=array(); + + //$TParam['limit']['nbLine'] = 99999; + + $this->init($TParam); + + $this->parse_array($TEntete, $TChamps, $TParam,$TField); + list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + return $this->renderList($TEntete, $TChamps, $TTotal,$TTotalGroup,$TParam); + + } + public function renderArray(&$db,$TField, $TParam=array()) { + $this->typeRender = 'array'; + // on conserve db pour le traitement ultérieur des subQuery + $TEntete=array(); + $TChamps=array(); + + $this->init($TParam); + + $this->parse_array($TEntete, $TChamps, $TParam,$TField); + list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + + $view_type = $this->getViewType($TParam); + + if($view_type == 'raw') { + return $this->renderRAW($TEntete, $TChamps,$TTotal, $TParam); + } + if($view_type == 'chart') { + return $this->renderChart($TEntete, $TChamps,$TTotal, $TParam); + } + else { + return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); + } + } + + private function order_by($sql, &$TParam) { + $first = true; + // print_r($TParam['orderBy']); + if(!empty($TParam['orderBy'])) { + + if(strpos($sql,'LIMIT ')!==false) { + list($sql, $sqlLIMIT) = explode('LIMIT ', $sql); + } + + $sql.=' ORDER BY '; + foreach($TParam['orderBy'] as $field=>$order) { + if(!$first) $sql.=','; + + if($order=='DESC')$TParam['liste']['orderDown'] = $field; + else $TParam['liste']['orderUp'] = $field; + + if(strpos($field,'.')===false) $sql.='`'.$field.'` '.$order; + else $sql.=$field.' '.$order; + + $first=false; + } + + if(!empty($sqlLIMIT))$sql.=' LIMIT '.$sqlLIMIT; + + } + + return $sql; + } + private function parse_xml(&$db, &$TEntete, &$TChamps, &$TParam, $xmlString) { + $xml = simplexml_load_string($xmlString); + $this->THideFlip = array_flip($TParam['hide']); + + $first=true; + foreach($xml->{$TParam['node']['main']}->{$TParam['node']['object']} as $node) { + if($first) { + $this->init_entete($TEntete, $TParam, $node); + $first=false; + } + + $this->set_line($TChamps, $TParam, $node); + } + + } + private function parse_array(&$TEntete, &$TChamps, &$TParam, $TField) { + $first=true; + + $this->THideFlip = array_flip($TParam['hide']); + $this->TTotalTmp=array(); + + if(empty($TField)) return false; + + foreach($TField as $row) { + if($first) { + $this->init_entete($TEntete, $TParam, $row); + $first=false; + } + + $this->set_line($TChamps, $TParam, $row); + } + + } + + private function init_entete(&$TEntete, &$TParam, $currentLine) { + + $TField=$TFieldVisibility=array(); + + foreach ($currentLine as $field => $value) { + $TField[$field]=true; + } + + global $user; + + $contextpage=md5($_SERVER['PHP_SELF']); + if((float)DOL_VERSION>=4.0 && empty($TParam['no-select'])) { + + dol_include_once('/core/class/html.form.class.php'); + + global $db,$conf,$user; + $form=new Form($db); + + $selectedfields = GETPOST('TListTBS_'.$this->id.'_selectedfields'); + + if(!empty($selectedfields)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $tabparam['MAIN_SELECTEDFIELDS_'.$contextpage]=$selectedfields; + $result=dol_set_user_param($db, $conf, $user, $tabparam); + } + + $tmpvar='MAIN_SELECTEDFIELDS_'.$contextpage; + if (! empty($user->conf->$tmpvar)) { + $tmparray=explode(',', $user->conf->$tmpvar); + $TParam['hide']=array(); + foreach($TField as $field=>$dummy) + { + $libelle = isset($TParam['title'][$field]) ? $TParam['title'][$field] : $field; + + if(!in_array($field,$tmparray)) { + $TParam['hide'][] = $field; + $visible = 0; + } + else{ + $visible = 1; + } + + $TFieldVisibility[$field]=array( + 'label'=>$libelle + ,'checked'=>$visible + ); + + + } + } + else{ + foreach($TField as $field=>$dummy) + { + $libelle = isset($TParam['title'][$field]) ? $TParam['title'][$field] : $field; + $visible = (!in_array($field,$TParam['hide'])) ? 1 : 0; + $TFieldVisibility[$field]=array( + 'label'=>$libelle + ,'checked'=>$visible + ); + } + } + + $selectedfields=$form->multiSelectArrayWithCheckbox('TListTBS_'.$this->id.'_selectedfields', $TFieldVisibility, $contextpage); // This also change content of $arrayfields_0 + + } + + foreach ($currentLine as $field => $value) { + $libelle = isset($TParam['title'][$field]) ? $TParam['title'][$field] : $field; + $visible = (!in_array($field,$TParam['hide'])) ? 1 : 0; + + if($visible) { + $lastfield = $field; + $TEntete[$field] = array( + 'libelle'=>$libelle + ,'order'=>((in_array($field, $TParam['orderby']['noOrder']) || $this->typeRender != 'sql') ? 0 : 1) + ,'width'=>(!empty($TParam['size']['width'][$field]) ? $TParam['size']['width'][$field] : 'auto') + ,'text-align'=>(!empty($TParam['position']['text-align'][$field]) ? $TParam['position']['text-align'][$field] : 'auto') + ,'more'=>'' + ); + + } + } + + if(!empty($selectedfields) && !empty($lastfield)) { + $TEntete[$lastfield]['more']='
'.$selectedfields.'
'; + } + + + /*if(!empty($TParam['search']) && !empty($TEntete)) { + $TEntete['actions']=array('libelle'=>'', 'order'=>0); + }*/ + + } + + private function in_view(&$TParam, $line_number) { + global $conf; +// var_dump($_REQUEST['get-all-for-export']); + if(!empty($_REQUEST['get-all-for-export'])) return true; // doit être dans la vue + + $page_number = !empty($TParam['limit']['page']) ? $TParam['limit']['page'] : 1; + $line_per_page = !empty($TParam['limit']['nbLine']) ? $TParam['limit']['nbLine'] : $conf->liste_limit; + + $start = ($page_number-1) * $line_per_page; + $end = ($page_number* $line_per_page) -1; + + if($line_number>=$start && $line_number<=$end) return true; + else return false; + } + + private function set_line(&$TChamps, &$TParam, $currentLine) { + + global $conf; + + $line_number = count($TChamps); + + if($this->in_view($TParam,$line_number)) { + + $row=array(); $trans = array(); + foreach($currentLine as $field=>$value) { + + if(is_object($value)) { + if(get_class($value)=='stdClass') {$value=print_r($value, true);} + else $value=(string)$value; + } + + if(isset($TParam['subQuery'][$field])) { + $dbSub = new TPDOdb; //TODO finish it + $dbSub->Execute( strtr($TParam['subQuery'][$field], array_merge( $trans, array('@val@'=>$value) )) ); + $subResult = ''; + while($dbSub->Get_line()) { + $subResult.= implode(', ',$dbSub->currentLine).'
'; + } + $value=$subResult; + $dbSub->close(); + } + + $trans['@'.$field.'@'] = $value; + + if(!empty($TParam['math'][$field])) { + $float_value = (double)strip_tags($value); + $this->TTotalTmp[$field][] = $float_value; + } + + if(!in_array($field,$TParam['hide'])) { + $row[$field]=$value; + + if(isset($TParam['eval'][$field]) && in_array($field,array_keys($row))) { + $strToEval = 'return '.strtr( $TParam['eval'][$field] , array_merge( $trans, array('@val@'=>$row[$field]) )).';'; + $row[$field] = eval($strToEval); + } + + if(isset($TParam['type'][$field]) && !isset($TParam['eval'][$field])) { + if($TParam['type'][$field]=='date' + || $TParam['type'][$field]=='datetime' ) { + + if($row[$field] != '0000-00-00 00:00:00' && $row[$field] != '1000-01-01 00:00:00' && $row[$field] != '0000-00-00' && !empty($row[$field])) { + if($TParam['type'][$field]=='datetime')$row[$field] = dol_print_date(strtotime($row[$field]),'dayhoursec'); + else $row[$field] = dol_print_date(strtotime($row[$field]),'day'); + } else { + $row[$field] = ''; + } + } + if($TParam['type'][$field]=='hour') { $row[$field] = date('H:i', strtotime($row[$field])); } + if($TParam['type'][$field]=='money') { $row[$field] = '
'.price($row[$field],0,'',1,-1,2).'
'; } + if($TParam['type'][$field]=='number') { $row[$field] = '
'.price($row[$field]).'
'; } + if($TParam['type'][$field]=='integer') { $row[$field] = '
'.(int)$row[$field].'
'; } + } + + if(isset($TParam['link'][$field])) { + if(empty($row[$field]) && $row[$field]!==0 && $row[$field]!=='0')$row[$field]='(vide)'; + $row[$field]= strtr( $TParam['link'][$field], array_merge( $trans, array('@val@'=>$row[$field]) )) ; + } + + if(isset($TParam['translate'][$field])) { + if(isset($TParam['translate'][$field][''])) unset($TParam['translate'][$field]['']); + $row[$field] = strtr( $row[$field] , $TParam['translate'][$field]); + } + + + } + + + } + } + else{ + $row=array(); + + foreach($currentLine as $field=>&$value) { + if(!isset($this->THideFlip[$field])) { + if(isset($TParam['math'][$field]) && !empty($TParam['math'][$field])) { + $float_value = (double)strip_tags($value); + $this->TTotalTmp[$field][] = $float_value; + } + + $row[$field] = $value; + } + } + } + + if(!empty($TParam['math'][$field])) { + foreach($row as $field=>$value) { + if(!empty($TParam['math'][$field]) && is_array($TParam['math'][$field])) { + $toField = $TParam['math'][$field][1]; + $float_value = (double)strip_tags($row[$toField]); + $this->TTotalTmp['@groupsum'][$toField][ $row[$field] ] +=$float_value; + + } + } + } + $TChamps[] = $row; + } + + private function getBind(&$TParam) { + + $TBind = array(); + foreach($this->TBind as $k=>$v) { + if(!empty($TParam['operator'][$k]) && $TParam['operator'][$k] == 'IN') { + + if($v==='')$TBind[$k] =array("'0'"); + else $TBind[$k] =explode(',', $v); + + } + else{ + $TBind[$k] = $v; + } + + } + + return $TBind; + } + + private function getSQL(&$PDOdb,$sql,&$TParam) { + global $user,$conf; + + $sql=strtr($sql,array( + '@current_user@'=>$user->id + )); + + //AA oui c'est moche mais le bindParam ne prends pas en compte les tableaux pour le IN ce qui est super pénalisant. En attendant de refaire mieux ou d'un coup de main + $TBind = $this->getBind($TParam); + + $sql = preg_replace_callback('/(:[a-z])\w+/i',function($matches) use($TBind,$PDOdb) { + $field = substr($matches[0],1); + if(isset($TBind[$field]) || is_null($TBind[$field]) ) { + + if(is_array($TBind[$field])) { + $r = ''; + foreach($TBind[$field] as $v ){ + if(!empty($r))$r.=','; + $r.=$PDOdb->quote($v); + } + + return $r; + + } + else if(strpos($TBind[$field],' IS NULL') === false) { + return $PDOdb->quote($TBind[$field]); + } + else { + return $TBind[$field]; + } + } + else { + return 'errorBindingField '.$field; + } + + }, $sql); + + + return $sql; + } + + private function limitSQL($sql,&$TParam) { + + if(!empty($TParam['limit']['global']) && strpos($sql,'LIMIT ')===false ) { + + $sql.=' LIMIT '.(int)$TParam['limit']['global']; + + } + + return $sql; + } + + private function parse_sql(&$PDOdb, &$TEntete, &$TChamps,&$TParam, $sql, $TBind=array()) { + + //$sql.=' LIMIT '.($TParam['limit']['page']*$TParam['limit']['nbLine']).','.$TParam['limit']['nbLine']; + $sql = $this->limitSQL($sql, $TParam); + + $this->TTotalTmp=array(); + + $this->sql = $this->getSQL($PDOdb,$sql,$TParam); + $this->THideFlip = array_flip($TParam['hide']); + + $res = $PDOdb->Execute($this->sql); + $first=true; + while($currentLine = $PDOdb->Get_line()) { + if($first) { + $this->init_entete($TEntete, $TParam, $currentLine); + $first = false; + } + + $this->set_line($TChamps, $TParam, $currentLine); + + } + +//pre($TChamps);exit; + + } +} diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 808dd7933be..60a8dde8652 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -69,9 +69,11 @@ class Inventory extends CoreObject ,'title'=>array('type'=>'string') ); - function __construct() + function __construct(&$db) { + $this->db = &$db; + parent::init(); $this->_init_vars(); @@ -316,22 +318,64 @@ class Inventory extends CoreObject return ''.img_picto('','object_list.png','',0).' '.$title.''; } + + static function getSQL($type) { + global $conf; + + if($type=='All') { + + $sql="SELECT i.rowid, e.label, i.date_inventory, i.fk_warehouse, i.date_cre, i.date_maj, i.status + FROM ".MAIN_DB_PREFIX."inventory i + LEFT JOIN ".MAIN_DB_PREFIX."entrepot e ON (e.rowid = i.fk_warehouse) + WHERE i.entity=".(int) $conf->entity; + + } + + return $sql; + } + } -class Inventorydet extends TObjetStd +class Inventorydet extends CoreObject { - function __construct() + public $element='inventorydet'; + public $table_element='inventorydet'; + protected $isnolinkedbythird = 1; // No field fk_soc + protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + public $fk_inventory; + public $fk_warehouse; + public $fk_product; + public $entity; + public $qty_view; + public $qty_stock; + public $qty_regulated; + public $pmp; + public $pa; + public $new_pmp; + + private $__fields=array( + 'fk_inventory'=>array('type'=>'int') + ,'fk_warehouse'=>array('type'=>'int') + ,'fk_product'=>array('type'=>'int') + ,'entity'=>array('type'=>'int') + ,'qty_view'=>array('type'=>'float') + ,'qty_stock'=>array('type'=>'float') + ,'qty_regulated'=>array('type'=>'float') + ,'pmp'=>array('type'=>'float') + ,'pa'=>array('type'=>'float') + ,'new_pmp'=>array('type'=>'float') + ); + + + function __construct(&$db) { global $conf; - $this->set_table(MAIN_DB_PREFIX.'inventorydet'); - $this->TChamps = array(); - $this->add_champs('fk_inventory,fk_warehouse,fk_product,entity', 'type=entier;'); - $this->add_champs('qty_view,qty_stock,qty_regulated,pmp,pa,new_pmp', 'type=float;'); - - $this->_init_vars(); - $this->start(); + $this->db = &$db; + parent::init(); + $this->entity = $conf->entity; $this->errors = array(); From dfb9ae234cfe3b156cedba54e72c36d8e88e19ea Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Dec 2016 19:03:02 +0100 Subject: [PATCH 003/172] debug --- htdocs/core/class/coreobject.class.php | 23 +- ...{class.listview.php => listview.class.php} | 520 +++--------------- htdocs/core/js/listview.js | 143 +++++ htdocs/inventory/class/inventory.class.php | 81 ++- 4 files changed, 266 insertions(+), 501 deletions(-) rename htdocs/core/class/{class.listview.php => listview.class.php} (61%) create mode 100644 htdocs/core/js/listview.js diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 1cc68f38cb7..7d784073412 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -25,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class CoreObject extends CommonObject { - + protected $__fields=array(); /** * Constructor * @@ -38,7 +38,7 @@ class CoreObject extends CommonObject { $this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? } - private function init() { + protected function init() { $this->id = 0; $this->datec = time(); @@ -110,20 +110,20 @@ class CoreObject extends CommonObject { } else return false; } - private function _is_float($info){ + private function is_float($info){ if(is_array($info)) { if(isset($info['type']) && $info['type']=='float') return true; else return false; } else return false; } - private function _is_text($info){ + private function is_text($info){ if(is_array($info)) { if(isset($info['type']) && $info['type']=='text') return true; else return false; } else return false; } - private function _is_index($info){ + private function is_index($info){ if(is_array($info)) { if(isset($info['index']) && $info['index']==true) return true; else return false; @@ -172,14 +172,23 @@ class CoreObject extends CommonObject { return $query; } + private function get_field_list(){ + + $keys = array_keys($this->__fields); + + return implode(',', $keys); + } public function fetch($id, $loadChild = true) { if(empty($id)) return false; - $res = $db->query( 'SELECT '.$this->get_field_list().'datec,tms + $sql = 'SELECT '.$this->get_field_list().',datec,tms FROM '.$this->table_element.' - WHERE rowid='.$id ); + WHERE rowid='.$id; + + $res = $this->db->query( $sql ); + var_dump($sql); if($obj = $db->fetch_object($res)) { $this->rowid=$id; diff --git a/htdocs/core/class/class.listview.php b/htdocs/core/class/listview.class.php similarity index 61% rename from htdocs/core/class/class.listview.php rename to htdocs/core/class/listview.class.php index f37fc9a1628..0cedad18855 100644 --- a/htdocs/core/class/class.listview.php +++ b/htdocs/core/class/listview.class.php @@ -20,7 +20,9 @@ class Listview { - function __construct( $id ) { + function __construct(&$db, $id ) { + + $this->db = &$db; $this->id = $id; @@ -263,79 +265,25 @@ class Listview { return $sql; } - private function getViewType(&$TParam) { - if(!empty($TParam['view_type'])) return $TParam['view_type']; - else if (is_string($TParam['type']))return $TParam['type'] ; - else return 'list'; + public function render($sql,$TParam=array()) { + + $THeader=array(); + $TField=array(); + + $this->init($TParam); + + $sql = $this->search($sql,$TParam); + $sql = $this->order_by($sql, $TParam); + + $this->parse_sql($THeader, $TField, $TParam, $sql); + + list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam); + + return $this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam); + } - public function render(&$db,$sql,$TParam=array(),$TBind=array()) { - $this->typeRender = 'sql'; - // print_r($TParam); - $TEntete=array(); - $TChamps=array(); - - $this->init($TParam); - - if(!empty($TBind)) $this->TBind = $TBind; - - $sql = $this->search($sql,$TParam); - $sql = $this->order_by($sql, $TParam); - - $this->parse_sql($db, $TEntete, $TChamps, $TParam, $sql); - - list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); - - $view_type = $this->getViewType($TParam); - - if($view_type == 'raw') { - return $this->renderRAW($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); - } - else if($view_type == 'chart') { - return $this->renderChart($TEntete, $TChamps,$TTotal, $TParam); - } - else { - return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); - } - - - } - public function renderDataTableAjax(&$db,$sql,$TParam=array()) { - $this->renderDataTableSQL($db, $sql, $TParam); - } - public function renderDataTableSQL(&$db,$sql,$TParam=array()) { - $this->typeRender = 'dataTableAjax'; - // print_r($TParam); - $TEntete=array(); - $TChamps=array(); - - $this->init($TParam); - - $sql = $this->search($sql,$TParam); - $sql = $this->order_by($sql, $TParam); - - $this->parse_sql($db, $TEntete, $TChamps, $TParam, $sql); - list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); - - return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); - - } - public function renderXML(&$db,$xmlString, $TParam=array()) { - $this->typeRender = 'xml'; - - $TEntete=array(); - $TChamps=array(); - - $this->init($TParam); - - $this->parse_xml($db, $TEntete, $TChamps, $TParam,$xmlString); - - list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); - - return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); - - } - private function setSearch(&$TEntete, &$TParam) { + private function setSearch(&$THeader, &$TParam) { global $langs; if(empty($TParam['search'])) return array(); @@ -347,7 +295,7 @@ class Listview { $nb_search_in_bar = 0; if(!empty($TParam['search'])) { - foreach($TEntete as $key=>$libelle) { // init + foreach($THeader as $key=>$libelle) { // init if(empty($TSearch[$key]))$TSearch[$key]=''; } } @@ -382,7 +330,7 @@ class Listview { } - if(!empty($TEntete[$key]) || $this->getViewType($TParam) == 'chart') { + if(!empty($THeader[$key]) || $this->getViewType($TParam) == 'chart') { $TSearch[$key] = $fsearch; $nb_search_in_bar++; } @@ -416,12 +364,12 @@ class Listview { * Function analysant et totalisant une colonne * Supporté : sum, average */ - private function get_total(&$TChamps, &$TParam) { + private function get_total(&$TField, &$TParam) { $TTotal=$TTotalGroup=array(); - if(!empty($TParam['math']) && !empty($TChamps[0])) { + if(!empty($TParam['math']) && !empty($TField[0])) { - foreach($TChamps[0] as $field=>$value) { + foreach($TField[0] as $field=>$value) { $TTotal[$field]=''; $TTotalGroup[$field] = ''; } @@ -460,80 +408,16 @@ class Listview { private function getJS(&$TParam) { $javaScript = ''; - - if($this->typeRender=='dataTable') { - - $javaScript.=' - '; - - $TPagination=array(); - } - elseif($this->typeRender=='dataTableAjax') { - $javaScript.=' - '; - } - return $javaScript; } - private function setExport(&$TParam,$TChamps,$TEntete) { + private function setExport(&$TParam,$TField,$THeader) { global $langs; $Tab=array(); @@ -545,8 +429,8 @@ class Listview { 'title'=>$this->title ,'sql'=>$this->sql ,'TBind'=>$this->TBind - ,'TChamps'=>$TChamps - ,'TEntete'=>$TEntete + ,'TChamps'=>$TField + ,'TEntete'=>$THeader ) ) ); foreach($TParam['export'] as $mode_export) { @@ -567,133 +451,7 @@ class Listview { return $Tab; } - private function renderChart(&$TEntete, &$TChamps,&$TTotal, &$TParam) { - - $TData = array(); - $header = ''; - $first = true; - - $TSearch = $this->setSearch($TEntete, $TParam); - $TExport= $this->setExport($TParam, $TChamps, $TEntete); - - if(empty($TParam['xaxis']) && !empty($TEntete)) { - $fieldXaxis = key($TEntete); - } - else { - $fieldXaxis = $TParam['xaxis']; - } - - $TValue=array(); $key = null; - foreach($TEntete as $field=>&$entete) { - if($field!=$fieldXaxis)$TValue[] = addslashes($entete['libelle']); - } - - $header='["'.addslashes( $TEntete[$fieldXaxis]['libelle'] ).'","'.implode('","', $TValue).'"]'; - //var_dump($fieldXaxis, $TChamps); - foreach($TChamps as &$row) { - $TValue=array(); - $key = null; - - foreach($row as $k=>$v) { - - if($k == $fieldXaxis) { - $key = $v; - } - else { - $TValue[] = (float)$v; - } - - } - - if(!is_null($key)) { - if(!isset($TData[$key])) $TData[$key] = $TValue; - else { - foreach($TData[$key] as $k=>$v) { - $TData[$key][$k]+=(float)$TValue[$k]; - } - - } - } - - - } - - $data = $header; - foreach($TData as $key=>$TValue) { - - $data .= ',[ "'.$key.'", '; - foreach($TValue as $v) { - $data.=(float)$v.','; - } - - $data.=' ]'; - } - - $height = empty($TParam['height']) ? 500 : $TParam['height']; - $curveType= empty($TParam['curveType']) ? 'none': $TParam['curveType']; // none or function - $pieHole = empty($TParam['pieHole']) ? 0: $TParam['pieHole']; // none or function - $hAxis = empty($TParam['hAxis']) ? array() : $TParam['hAxis']; // Array of params - $vAxis = empty($TParam['vAxis']) ? array() : $TParam['vAxis']; // Array of params - - // This feature is experimental and may change in future releases - $explorer = empty($TParam['explorer']) ? array() : $TParam['explorer']; // Note: The explorer only works with continuous axes (such as numbers or dates) - - $type = empty($TParam['chartType']) ? 'LineChart' : $TParam['chartType']; - - $html = ''; - - if(!empty($TSearch)) { - - $html.=''; - foreach($TSearch as $field=>$input) { - if(!empty($input)) { - $label = !empty($TParam['title'][$field]) ? $TParam['title'][$field] : $field; - $html.=''; - } - } - - $html.=''; - - } - $javaScript = $this->getJS($TParam); - - $html.=' - -
- '.$javaScript; - - return $html; - } - - private function addTotalGroup($TChamps,$TTotalGroup) { + private function addTotalGroup($TField,$TTotalGroup) { global $langs; $Tab=array(); @@ -704,7 +462,7 @@ class Listview { $addGroupLine = false; - foreach($TChamps as $k=>&$line) { + foreach($TField as $k=>&$line) { if(empty($proto_total_line)) { foreach($line as $field=>$value) { @@ -748,99 +506,50 @@ class Listview { return $Tab; } - - private function renderRAW(&$TEntete, &$TChamps, &$TTotal,&$TTotalGroup, &$TParam) { - $TSearch = $this->setSearch($TEntete, $TParam); - $TExport=$this->setExport($TParam, $TChamps, $TEntete); - $TChamps = $this->addTotalGroup($TChamps,$TTotalGroup); - - return array( - 'entete'=>$TEntete - ,'champs'=>$TChamps - ,'recherche'=>$TSearch - ,'total'=>$TTotal - ,'export'=>$TExport - ,'haveExport'=>count($TExport) - , 'id'=>$this->id - , 'nb_columns'=>count($TEntete) - ,'totalNB'=>count($TChamps) - , 'nbSearch'=>count($TSearch) - , 'haveTotal'=>(int)!empty($TTotal) - , 'havePage'=>(int)!empty($TPagination) - ); - } - private function renderList(&$TEntete, &$TChamps, &$TTotal,&$TTotalGroup, &$TParam) { - $TBS = new TTemplateTBS; - + private function renderList(&$THeader, &$TField, &$TTotal,&$TTotalGroup, &$TParam) { + $javaScript = $this->getJS($TParam); - if($this->typeRender!='dataTableAjax') { - $TPagination=array( - 'pagination'=>array('pageSize'=>$TParam['limit']['nbLine'], 'pageNum'=>$TParam['limit']['page'], 'blockName'=>'champs', 'totalNB'=>count($TChamps)) - ); - } - else { - $TPagination=array(); - } + $TPagination=array( + 'pagination'=>array('pageSize'=>$TParam['limit']['nbLine'], 'pageNum'=>$TParam['limit']['page'], 'blockName'=>'champs', 'totalNB'=>count($TField)) + ); - $TSearch = $this->setSearch($TEntete, $TParam); - $TExport=$this->setExport($TParam, $TChamps, $TEntete); - $TChamps = $this->addTotalGroup($TChamps,$TTotalGroup); + $TSearch = $this->setSearch($THeader, $TParam); + $TExport=$this->setExport($TParam, $TField, $THeader); + $TField = $this->addTotalGroup($TField,$TTotalGroup); - return $TBS->render($this->template - , array( - 'entete'=>$TEntete - ,'champs'=>$TChamps + var_dump( + array( + 'entete'=>$THeader + ,'champs'=>$TField ,'recherche'=>$TSearch ,'total'=>$TTotal ,'export'=>$TExport ) , array( - 'liste'=>array_merge(array('haveExport'=>count($TExport), 'id'=>$this->id, 'nb_columns'=>count($TEntete) ,'totalNB'=>count($TChamps), 'nbSearch'=>count($TSearch), 'haveTotal'=>(int)!empty($TTotal), 'havePage'=>(int)!empty($TPagination) ), $TParam['liste']) + 'liste'=>array_merge(array('haveExport'=>count($TExport), 'id'=>$this->id, 'nb_columns'=>count($THeader) ,'totalNB'=>count($TField), 'nbSearch'=>count($TSearch), 'haveTotal'=>(int)!empty($TTotal), 'havePage'=>(int)!empty($TPagination) ), $TParam['liste']) ) , $TPagination - , array() - ) - .$javaScript; - } - public function renderDatatable(&$db, $TField, $TParam) { - $this->typeRender = 'dataTable'; - // on conserve db pour le traitement ultérieur des subQuery - $TEntete=array(); - $TChamps=array(); - - //$TParam['limit']['nbLine'] = 99999; - - $this->init($TParam); - - $this->parse_array($TEntete, $TChamps, $TParam,$TField); - list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); - return $this->renderList($TEntete, $TChamps, $TTotal,$TTotalGroup,$TParam); - + + ); + + $javaScript; } + public function renderArray(&$db,$TField, $TParam=array()) { $this->typeRender = 'array'; // on conserve db pour le traitement ultérieur des subQuery - $TEntete=array(); - $TChamps=array(); + $THeader=array(); + $TField=array(); $this->init($TParam); - $this->parse_array($TEntete, $TChamps, $TParam,$TField); - list($TTotal, $TTotalGroup)=$this->get_total($TChamps, $TParam); + $this->parse_array($THeader, $TField, $TParam,$TField); + list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam); - $view_type = $this->getViewType($TParam); + $this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam); - if($view_type == 'raw') { - return $this->renderRAW($TEntete, $TChamps,$TTotal, $TParam); - } - if($view_type == 'chart') { - return $this->renderChart($TEntete, $TChamps,$TTotal, $TParam); - } - else { - return $this->renderList($TEntete, $TChamps,$TTotal,$TTotalGroup, $TParam); - } } private function order_by($sql, &$TParam) { @@ -848,7 +557,7 @@ class Listview { // print_r($TParam['orderBy']); if(!empty($TParam['orderBy'])) { - if(strpos($sql,'LIMIT ')!==false) { + if(strpos($sql,'LIMIT ')!==false) { //TODO regex list($sql, $sqlLIMIT) = explode('LIMIT ', $sql); } @@ -871,22 +580,8 @@ class Listview { return $sql; } - private function parse_xml(&$db, &$TEntete, &$TChamps, &$TParam, $xmlString) { - $xml = simplexml_load_string($xmlString); - $this->THideFlip = array_flip($TParam['hide']); - - $first=true; - foreach($xml->{$TParam['node']['main']}->{$TParam['node']['object']} as $node) { - if($first) { - $this->init_entete($TEntete, $TParam, $node); - $first=false; - } - - $this->set_line($TChamps, $TParam, $node); - } - - } - private function parse_array(&$TEntete, &$TChamps, &$TParam, $TField) { + + private function parse_array(&$THeader, &$TField, &$TParam, $TField) { $first=true; $this->THideFlip = array_flip($TParam['hide']); @@ -896,16 +591,16 @@ class Listview { foreach($TField as $row) { if($first) { - $this->init_entete($TEntete, $TParam, $row); + $this->init_entete($THeader, $TParam, $row); $first=false; } - $this->set_line($TChamps, $TParam, $row); + $this->set_line($TField, $TParam, $row); } } - private function init_entete(&$TEntete, &$TParam, $currentLine) { + private function init_entete(&$THeader, &$TParam, $currentLine) { $TField=$TFieldVisibility=array(); @@ -977,7 +672,7 @@ class Listview { if($visible) { $lastfield = $field; - $TEntete[$field] = array( + $THeader[$field] = array( 'libelle'=>$libelle ,'order'=>((in_array($field, $TParam['orderby']['noOrder']) || $this->typeRender != 'sql') ? 0 : 1) ,'width'=>(!empty($TParam['size']['width'][$field]) ? $TParam['size']['width'][$field] : 'auto') @@ -989,19 +684,15 @@ class Listview { } if(!empty($selectedfields) && !empty($lastfield)) { - $TEntete[$lastfield]['more']='
'.$selectedfields.'
'; + $THeader[$lastfield]['more']='
'.$selectedfields.'
'; } - /*if(!empty($TParam['search']) && !empty($TEntete)) { - $TEntete['actions']=array('libelle'=>'', 'order'=>0); - }*/ - } private function in_view(&$TParam, $line_number) { global $conf; -// var_dump($_REQUEST['get-all-for-export']); + if(!empty($_REQUEST['get-all-for-export'])) return true; // doit être dans la vue $page_number = !empty($TParam['limit']['page']) ? $TParam['limit']['page'] : 1; @@ -1014,11 +705,11 @@ class Listview { else return false; } - private function set_line(&$TChamps, &$TParam, $currentLine) { + private function set_line(&$TField, &$TParam, $currentLine) { global $conf; - $line_number = count($TChamps); + $line_number = count($TField); if($this->in_view($TParam,$line_number)) { @@ -1114,67 +805,7 @@ class Listview { } } } - $TChamps[] = $row; - } - - private function getBind(&$TParam) { - - $TBind = array(); - foreach($this->TBind as $k=>$v) { - if(!empty($TParam['operator'][$k]) && $TParam['operator'][$k] == 'IN') { - - if($v==='')$TBind[$k] =array("'0'"); - else $TBind[$k] =explode(',', $v); - - } - else{ - $TBind[$k] = $v; - } - - } - - return $TBind; - } - - private function getSQL(&$PDOdb,$sql,&$TParam) { - global $user,$conf; - - $sql=strtr($sql,array( - '@current_user@'=>$user->id - )); - - //AA oui c'est moche mais le bindParam ne prends pas en compte les tableaux pour le IN ce qui est super pénalisant. En attendant de refaire mieux ou d'un coup de main - $TBind = $this->getBind($TParam); - - $sql = preg_replace_callback('/(:[a-z])\w+/i',function($matches) use($TBind,$PDOdb) { - $field = substr($matches[0],1); - if(isset($TBind[$field]) || is_null($TBind[$field]) ) { - - if(is_array($TBind[$field])) { - $r = ''; - foreach($TBind[$field] as $v ){ - if(!empty($r))$r.=','; - $r.=$PDOdb->quote($v); - } - - return $r; - - } - else if(strpos($TBind[$field],' IS NULL') === false) { - return $PDOdb->quote($TBind[$field]); - } - else { - return $TBind[$field]; - } - } - else { - return 'errorBindingField '.$field; - } - - }, $sql); - - - return $sql; + $TField[] = $row; } private function limitSQL($sql,&$TParam) { @@ -1188,29 +819,26 @@ class Listview { return $sql; } - private function parse_sql(&$PDOdb, &$TEntete, &$TChamps,&$TParam, $sql, $TBind=array()) { + private function parse_sql( &$THeader, &$TField,&$TParam, $sql) { + global $db; - //$sql.=' LIMIT '.($TParam['limit']['page']*$TParam['limit']['nbLine']).','.$TParam['limit']['nbLine']; - $sql = $this->limitSQL($sql, $TParam); + $this->sql = $this->limitSQL($sql, $TParam); $this->TTotalTmp=array(); - $this->sql = $this->getSQL($PDOdb,$sql,$TParam); $this->THideFlip = array_flip($TParam['hide']); - $res = $PDOdb->Execute($this->sql); + $res = $db->query($this->sql); $first=true; - while($currentLine = $PDOdb->Get_line()) { + while($currentLine = $db->fetch_object($res)) { if($first) { - $this->init_entete($TEntete, $TParam, $currentLine); + $this->init_entete($THeader, $TParam, $currentLine); $first = false; } - $this->set_line($TChamps, $TParam, $currentLine); + $this->set_line($TField, $TParam, $currentLine); } -//pre($TChamps);exit; - } } diff --git a/htdocs/core/js/listview.js b/htdocs/core/js/listview.js new file mode 100644 index 00000000000..1157c2ef4b8 --- /dev/null +++ b/htdocs/core/js/listview.js @@ -0,0 +1,143 @@ +var TListTBS_include = true; + +function TListTBS_OrderDown(idListe, column) { + var base_url = document.location.href; + + base_url = TListTBS_recup_form_param(idListe,base_url); + base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]'); + + base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + + document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC"); +} +function TListTBS_OrderUp(idListe, column) { + + var base_url = document.location.href; + + base_url = TListTBS_recup_form_param(idListe,base_url); + base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]'); + + base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + + document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC"); +} +function TListTBS_modifyUrl(strURL,paramName,paramNewValue){ + if (strURL.indexOf(paramName+'=')!=-1){ + + var strFirstPart=strURL.substring(0,strURL.indexOf(paramName+'=',0))+paramName+'='; + var strLastPart=""; + if (strURL.indexOf('&',strFirstPart.length-1)>0) + strLastPart=strURL.substring(strURL.indexOf('&',strFirstPart.length-1),strURL.length); + strURL=strFirstPart+paramNewValue+strLastPart; + } + else{ + if (strURL.search('=')!=-1) // permet de verifier s'il y a dej� des param�tres dans l'URL + strURL+='&'+paramName+'='+paramNewValue; + else + strURL+='?'+paramName+'='+paramNewValue; + } + + return strURL; +} +function TListTBS_removeParam(strURL, paramMask) { + var cpt=0; + var url = ''; + + while(strURL.indexOf(paramMask)!=-1 && cpt++ <50){ + var strFirstPart= strURL.substring(0,strURL.indexOf(paramMask)-1); + + var strLastPart=''; + if (strURL.indexOf('&',strFirstPart.length+1)>0) { + strLastPart = strURL.substring(strURL.indexOf('&',strFirstPart.length+1),strURL.length); + } + + url = strFirstPart+strLastPart; + + } + + if(url=='')url = strURL; + + return url; +} + +function TListTBS_recup_form_param(idListe,base_url) { + + $('#'+idListe+' tr.barre-recherche [listviewtbs],#'+idListe+' tr.barre-recherche-head input,#'+idListe+' tr.barre-recherche-head select,#'+idListe+' div.tabsAction input[listviewtbs]').each(function(i,item) { + if($(item).attr("name")) { + base_url = TListTBS_modifyUrl(base_url, $(item).attr("name") , $(item).val()); + } + + }); + + return base_url; +} + +function TListTBS_GoToPage(idListe,pageNumber){ + + var base_url = document.location.href; + + base_url = TListTBS_recup_form_param(idListe,base_url); + base_url =TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][page]",pageNumber); + + base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + + document.location.href=base_url; +} +function TListTBS_submitSearch(obj) { + + $(obj).closest('form').submit(); + //console.log($(obj).closest('form')); +} +function TListTBS_launch_downloadAs(mode,url,token,session_name) { + $('#listTBSdAS_export_form').remove(); + + $form = $('
'); + $form.append(''); + $form.append(''); + $form.append(''); + + $('body').append($form); + + $('#listTBSdAS_export_form').submit(); + +} + +function TListTBS_downloadAs(obj, mode,url,token,session_name) { + + $form = $(obj).closest('form'); + $div = $form.find('div.tabsAction'); + $div.append(''); + $div.append(''); + $div.append(''); + $div.append(''); + $div.append(''); + + TListTBS_submitSearch(obj); +} + +$(document).ready(function() { + $('tr.barre-recherche input').keypress(function(e) { + if(e.which == 13) { + + var id_list = $(this).closest('table').attr('id'); + + $('#'+id_list+' .list-search-link').click(); + + } + }); + + var $_GET = {}; + + document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { + function decode(s) { + return decodeURIComponent(s.split("+").join(" ")); + } + + $_GET[decode(arguments[1])] = decode(arguments[2]); + }); + + if(typeof $_GET["get-all-for-export"] != "undefined") { + TListTBS_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]); + } + +}); diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 60a8dde8652..f158ab260cf 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -61,7 +61,7 @@ class Inventory extends CoreObject */ public $title; - private $__fields=array( + protected $__fields=array( 'fk_warehouse'=>array('type'=>'integer','index'=>true) ,'entity'=>array('type'=>'integer','index'=>true) ,'status'=>array('type'=>'integer','index'=>true) @@ -69,20 +69,14 @@ class Inventory extends CoreObject ,'title'=>array('type'=>'string') ); - function __construct(&$db) + function __construct(DoliDB &$db) { $this->db = &$db; parent::init(); - $this->_init_vars(); - - $this->start(); - - $this->setChild('Inventorydet','fk_inventory'); - - $this->status = 0; + $this->status = 0; $this->entity = $conf->entity; $this->errors = array(); $this->amount = 0; @@ -94,12 +88,12 @@ class Inventory extends CoreObject usort($this->Inventorydet, array('Inventory', 'customSort')); } - function load(&$PDOdb, $id,$annexe = true) + function fetch($id,$annexe = true) { if(!$annexe) $this->withChild = false; - $res = parent::load($PDOdb, $id); + $res = parent::fetch($id); $this->sort_det(); $this->amount = 0; @@ -124,7 +118,7 @@ class Inventory extends CoreObject return $r; } - function changePMP(&$PDOdb) { + function changePMP() { foreach ($this->Inventorydet as $k => &$Inventorydet) { @@ -133,16 +127,9 @@ class Inventory extends CoreObject $Inventorydet->pmp = $Inventorydet->new_pmp; $Inventorydet->new_pmp = 0; - $PDOdb->Execute("UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$Inventorydet->pmp." + $db->query("UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$Inventorydet->pmp." WHERE rowid = ".$Inventorydet->fk_product ); - if((float)DOL_VERSION<4.0) { - - $PDOdb->Execute("UPDATE ".MAIN_DB_PREFIX."product_stock SET pmp=".$Inventorydet->pmp." - WHERE fk_entrepot = ".$this->fk_warehouse." AND fk_product = ".$Inventorydet->fk_product) ; - - } - } } @@ -150,15 +137,15 @@ class Inventory extends CoreObject } - function save(&$PDOdb) + function update() { //si on valide l'inventaire on sauvegarde le stock à cette instant if ($this->status) { - $this->regulate($PDOdb); + $this->regulate(); } - parent::save($PDOdb); + parent::update(); } function set_values($Tab) @@ -188,24 +175,24 @@ class Inventory extends CoreObject return parent::set_values($Tab); } - function deleteAllLine(&$PDOdb) { + function deleteAllLine() { foreach($this->Inventorydet as &$det) { $det->to_delete = true; } - $this->save($PDOdb); + $this->update(); $this->Inventorydet=array(); } - function add_product(&$PDOdb, $fk_product, $fk_entrepot='') { + function add_product($fk_product, $fk_entrepot='') { - $k = $this->addChild($PDOdb, 'Inventorydet'); + $k = $this->addChild('Inventorydet'); $det = &$this->Inventorydet[$k]; - $det->fk_inventory = $this->getId(); + $det->fk_inventory = $this->id; $det->fk_product = $fk_product; $det->fk_warehouse = empty($fk_entrepot) ? $this->fk_warehouse : $fk_entrepot; @@ -213,16 +200,16 @@ class Inventory extends CoreObject $date = $this->get_date('date_inventory', 'Y-m-d'); if(empty($date))$date = $this->get_date('date_cre', 'Y-m-d'); - $det->setStockDate($PDOdb, $date , $fk_entrepot); + $det->setStockDate( $date , $fk_entrepot); } - function correct_stock($fk_product, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $inventorycode='') + function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') { global $conf, $db, $langs, $user; /* duplication method product to add datem */ - if ($id_entrepot) + if ($fk_warehouse) { $db->begin(); @@ -234,7 +221,7 @@ class Inventory extends CoreObject $datem = empty($conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT) ? dol_now() : $this->date_inventory; $movementstock=new MouvementStock($db); - $result=$movementstock->_create($user,$fk_product,$id_entrepot,$op[$movement],$movement,$price,$label,$inventorycode, $datem); + $result=$movementstock->_create($user,$fk_product,$fk_warehouse,$op[$movement],$movement,$price,$label,$inventorycode, $datem); if ($result >= 0) { @@ -252,7 +239,7 @@ class Inventory extends CoreObject } } - function regulate(&$PDOdb) + function regulate() { global $db,$user,$langs,$conf; @@ -288,10 +275,10 @@ class Inventory extends CoreObject $nbpiece = abs($Inventorydet->qty_regulated); $movement = (int) ($Inventorydet->qty_view < $Inventorydet->qty_stock); // 0 = add ; 1 = remove - $href = dol_buildpath('/inventory/inventory.php?id='.$this->getId().'&action=view', 1); + $href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1); if(empty($this->title)) - $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock', $href, $this->getId())); + $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock', $href, $this->id)); else $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStockWithNomInventaire', $href, $this->title)); } @@ -306,16 +293,14 @@ class Inventory extends CoreObject } static function getLink($id) { - global $langs; + global $langs,$db; - $PDOdb=new TPDOdb; + $i = new Inventory($db); + $i->fetch($id, false); - $i = new Inventory; - $i->load($PDOdb, $id, false); + $title = !empty($i->title) ? $i->title : $langs->trans('inventoryTitle').' '.$i->id; - $title = !empty($i->title) ? $i->title : $langs->trans('inventoryTitle').' '.$i->getId(); - - return ''.img_picto('','object_list.png','',0).' '.$title.''; + return ''.img_picto('','object_list.png','',0).' '.$title.''; } @@ -354,7 +339,7 @@ class Inventorydet extends CoreObject public $pa; public $new_pmp; - private $__fields=array( + protected $__fields=array( 'fk_inventory'=>array('type'=>'int') ,'fk_warehouse'=>array('type'=>'int') ,'fk_product'=>array('type'=>'int') @@ -385,11 +370,11 @@ class Inventorydet extends CoreObject } - function load(&$PDOdb, $id) + function fetch($id) { global $conf; - $res = parent::load($PDOdb, $id); + $res = parent::fetch($id); $this->load_product(); $this->fetch_current_pa(); @@ -431,9 +416,9 @@ class Inventorydet extends CoreObject AND datem<='".$date." 23:59:59' ORDER BY datem DESC LIMIT 1"; - $PDOdb->Execute($sql); + $res = $db->query($sql); - if($obj = $PDOdb->Get_line()) { + if($obj = $db->fetch_object($res)) { $last_pa = $obj->price; } @@ -467,7 +452,7 @@ class Inventorydet extends CoreObject ORDER BY datem DESC"; //echo $sql.'
'; - $PDOdb->Execute($sql); + $db->query($sql); $TMouvementStock = $PDOdb->Get_All(); $laststock = $stock; $lastpmp = $pmp; From baf1acb4fdb861bf8923f9dfc65adae22befd088 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 13 Dec 2016 09:17:43 +0100 Subject: [PATCH 004/172] debug --- htdocs/core/class/coreobject.class.php | 80 +++++++++++++++++++--- htdocs/core/class/listview.class.php | 28 +++++--- htdocs/inventory/class/inventory.class.php | 17 +++-- 3 files changed, 101 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 7d784073412..dc52fdd9bf5 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -25,6 +25,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class CoreObject extends CommonObject { + public $db; + protected $__fields=array(); /** * Constructor @@ -33,8 +35,6 @@ class CoreObject extends CommonObject { */ function __construct(DoliDB &$db) { - $this->db = &$db; - $this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? } @@ -179,27 +179,55 @@ class CoreObject extends CommonObject { return implode(',', $keys); } + private function set_vars_by_db(&$obj){ + + foreach ($this->__fields as $field=>$info) { + if($this->is_date($info)){ + if($obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00')$this->{$field} = 0; + else $this->{$field} = strtotime($obj->{$field}); + } + elseif($this->is_array($info)){ + $this->{$field} = @unserialize($obj->{$field}); + //HACK POUR LES DONNES NON UTF8 + if($this->{$field}===FALSE)@unserialize(utf8_decode($obj->{$field})); + } + elseif($this->is_int($info)){ + $this->{$field} = (int)$obj->{$field}; + } + elseif($this->is_float($info)){ + $this->{$field} = (double)$obj->{$field}; + } + elseif($this->is_null($info)){ + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0')?null:$val); + } + else{ + $this->{$field} = $obj->{$field}; + } + + } + } + public function fetch($id, $loadChild = true) { if(empty($id)) return false; $sql = 'SELECT '.$this->get_field_list().',datec,tms - FROM '.$this->table_element.' + FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$id; - + var_dump($sql); $res = $this->db->query( $sql ); - var_dump($sql); - if($obj = $db->fetch_object($res)) { + + if($obj = $this->db->fetch_object($res)) { $this->rowid=$id; - $this->set_vars_by_db($db); + $this->set_vars_by_db($obj); $this->datec=$this->db->idate($obj->datec); $this->tms=$this->db->idate($obj->tms); - if($loadChild) $this->loadChild($db); - - $this->run_trigger($db, 'load'); + if($loadChild) $this->fetchChild(); return $this->id; } @@ -208,6 +236,38 @@ class CoreObject extends CommonObject { } } + + public function fetchChild() { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { + + foreach($this->childtables as &$childTable) { + + $className = ucfirst($childTable); + + $this->{$className}=array(); + + $sql = " SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element."=".$this->rowid; + $res = $this->db->query($sql); + if($res) { + + while($obj = $db->fetch_object($res)) { + + $o=new $className($this->db); + $o->fetch($obj->rowid); + + $this->{$className}[] = $o; + + } + + } + + } + + } + + } + + public function update() { diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 0cedad18855..8df337b699c 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -820,7 +820,6 @@ class Listview { } private function parse_sql( &$THeader, &$TField,&$TParam, $sql) { - global $db; $this->sql = $this->limitSQL($sql, $TParam); @@ -828,17 +827,26 @@ class Listview { $this->THideFlip = array_flip($TParam['hide']); - $res = $db->query($this->sql); - $first=true; - while($currentLine = $db->fetch_object($res)) { - if($first) { - $this->init_entete($THeader, $TParam, $currentLine); - $first = false; + $res = $this->db->query($this->sql); + if($res!==false) { + + dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_DEBUG); + + $first=true; + while($currentLine = $this->db->fetch_object($res)) { + if($first) { + $this->init_entete($THeader, $TParam, $currentLine); + $first = false; + } + + $this->set_line($TField, $TParam, $currentLine); + } - $this->set_line($TField, $TParam, $currentLine); - } - + else { + dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_ERR); + } + } } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index f158ab260cf..d092a876ad2 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -69,6 +69,8 @@ class Inventory extends CoreObject ,'title'=>array('type'=>'string') ); + public $db; + function __construct(DoliDB &$db) { @@ -292,15 +294,22 @@ class Inventory extends CoreObject return 1; } + public function getNomUrl($picto = 1) { + global $langs; + + $title = !empty($this->title) ? $this->title : $langs->trans('inventoryTitle').' '.$this->id; + + return ''.($picto ? img_picto('','object_list.png','',0).' ' : '').$title.''; + + } + static function getLink($id) { global $langs,$db; $i = new Inventory($db); $i->fetch($id, false); - $title = !empty($i->title) ? $i->title : $langs->trans('inventoryTitle').' '.$i->id; - - return ''.img_picto('','object_list.png','',0).' '.$title.''; + return $i->getNomUrl(); } @@ -309,7 +318,7 @@ class Inventory extends CoreObject if($type=='All') { - $sql="SELECT i.rowid, e.label, i.date_inventory, i.fk_warehouse, i.date_cre, i.date_maj, i.status + $sql="SELECT i.rowid, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status FROM ".MAIN_DB_PREFIX."inventory i LEFT JOIN ".MAIN_DB_PREFIX."entrepot e ON (e.rowid = i.fk_warehouse) WHERE i.entity=".(int) $conf->entity; From efc22a4cd8b8dc4b6ea9c6be07c37eba0466def6 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 13 Dec 2016 09:49:59 +0100 Subject: [PATCH 005/172] include default list conception --- htdocs/core/class/coreobject.class.php | 7 +- htdocs/core/class/listview.class.php | 159 +++++++++++++-------- htdocs/inventory/class/inventory.class.php | 11 +- 3 files changed, 113 insertions(+), 64 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index dc52fdd9bf5..96cbbb89a88 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -27,6 +27,8 @@ class CoreObject extends CommonObject { public $db; + public $withChild = true; + protected $__fields=array(); /** * Constructor @@ -216,7 +218,7 @@ class CoreObject extends CommonObject { $sql = 'SELECT '.$this->get_field_list().',datec,tms FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$id; - var_dump($sql); + $res = $this->db->query( $sql ); if($obj = $this->db->fetch_object($res)) { @@ -238,8 +240,8 @@ class CoreObject extends CommonObject { } public function fetchChild() { - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { foreach($this->childtables as &$childTable) { $className = ucfirst($childTable); @@ -248,6 +250,7 @@ class CoreObject extends CommonObject { $sql = " SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element."=".$this->rowid; $res = $this->db->query($sql); + if($res) { while($obj = $db->fetch_object($res)) { diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 8df337b699c..db66f9f15a3 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -41,33 +41,30 @@ class Listview { if(!isset($TParam['orderby']['noOrder']))$TParam['orderby']['noOrder']=array(); if(!isset($TParam['no-select'])) $TParam['no-select'] = 1; - if(!isset($TParam['liste']))$TParam['liste']=array(); - $TParam['liste'] = array_merge(array( - 'messageNothing'=>"Il n'y a aucun élément à afficher." - ,'picto_precedent'=>'<' - ,'picto_suivant'=>'>' - ,'order_down'=>img_down() - ,'order_up'=>img_up() + if(!isset($TParam['list']))$TParam['list']=array(); + $TParam['list'] = array_merge(array( + 'messageNothing'=>$langs->trans('ListMessageNothingToShow') ,'noheader'=>0 ,'useBottomPagination'=>0 ,'image'=>'' - ,'titre'=>'Liste' + ,'title'=>$langs->trans('List') ,'orderDown'=>'' ,'orderUp'=>'' ,'id'=>$this->id - ,'picto_search'=>img_picto('Search', 'search.png') ,'head_search'=>'' ,'export'=>array() - ,'view_type'=>'' - ),$TParam['liste']); + ,'view_type'=>'' //TODO to include graph or kanban instead of list + ),$TParam['list']); + + $POSTList = GETPOST('Listview'); if(empty($TParam['limit']))$TParam['limit']=array(); - if(!empty($_REQUEST['TListTBS'][$this->id]['page'])) $TParam['limit']['page'] = $_REQUEST['TListTBS'][$this->id]['page']; + if(!empty($POSTList[$this->id]['page'])) $TParam['limit']['page'] = $POSTList[$this->id]['page']; $TParam['limit']=array_merge(array('page'=>1, 'nbLine'=>$conf->liste_limit, 'global'=>0), $TParam['limit']); - if(!empty($_REQUEST['TListTBS'][$this->id]['orderBy'])) { - $TParam['orderBy'] = $_REQUEST['TListTBS'][$this->id]['orderBy']; + if(!empty($POSTList[$this->id]['orderBy'])) { + $TParam['orderBy'] = $POSTList[$this->id]['orderBy']; } // print_r($TParam); @@ -124,9 +121,9 @@ class Listview { // Si le type de "recherche" est "calendars" on a 2 champs de transmis, [début et fin] ou [que début] ou [que fin] => un BETWEEN Sql serait utile que dans le 1er cas // donc l'utilisation des opérateur >= et <= permettent un fonctionnement générique $TSQLDate=array(); - if(!empty($value['deb'])) + if(!empty($value['start'])) { - $valueDeb = $this->dateToSQLDate($value['deb']); + $valueDeb = $this->dateToSQLDate($value['start']); if(isset($this->TBind[$sBindKey.'_start'])) // TODO can't use this in query case { @@ -137,9 +134,9 @@ class Listview { } - if(!empty($value['fin'])) + if(!empty($value['end'])) { - $valueFin = $this->dateToSQLDate($value['fin']); + $valueFin = $this->dateToSQLDate($value['end']); if(isset($this->TBind[$sBindKey.'_end'])) { // TODO can't use this in query case $this->TBind[$sBindKey.'_end'] = $valueFin; } @@ -198,7 +195,7 @@ class Listview { private function search($sql,&$TParam) { - if(!empty($_REQUEST['TListTBS'][$this->id]['search'])) { + if(!empty($_REQUEST['Listview'][$this->id]['search'])) { $sqlGROUPBY=''; if(strpos($sql,'GROUP BY')!==false) { //TODO regex list($sql, $sqlGROUPBY) = explode('GROUP BY', $sql); @@ -206,7 +203,7 @@ class Listview { if(strpos($sql,'WHERE ')===false)$sql.=' WHERE 1 '; //TODO regex - foreach($_REQUEST['TListTBS'][$this->id]['search'] as $key=>$value) + foreach($_REQUEST['Listview'][$this->id]['search'] as $key=>$value) { $TsKey = $this->getSearchKey($key, $TParam); $TsBindKey = $this->getTsBindKey($TsKey); @@ -222,7 +219,7 @@ class Listview { //if (!empty($value)) var_dump($sKey); $sBindKey = $TsBindKey[$i]; - if($allow_is_null && !empty($_REQUEST['TListTBS'][$this->id]['search_on_null'][$key])) + if($allow_is_null && !empty($_REQUEST['Listview'][$this->id]['search_on_null'][$key])) { $this->TBind[$sBindKey.'_null'] = $sKey.' IS NULL '; $TSQLMore[] = $sKey.' IS NULL '; @@ -302,31 +299,31 @@ class Listview { foreach($TParam['search'] as $key=>$param_search) { - $value = isset($_REQUEST['TListTBS'][$this->id]['search'][$key]) ? $_REQUEST['TListTBS'][$this->id]['search'][$key] : ''; + $value = isset($_REQUEST['Listview'][$this->id]['search'][$key]) ? $_REQUEST['Listview'][$this->id]['search'][$key] : ''; $typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search; if(is_array($typeRecherche)) { $typeRecherche = array(''=>' ') + $typeRecherche; - $fsearch=$form->combo('','TListTBS['.$this->id.'][search]['.$key.']', $typeRecherche,$value,0,'',' listviewtbs="combo" init-value="'.$value.'" '); + $fsearch=$form->combo('','Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,0,'',' listviewtbs="combo" init-value="'.$value.'" '); } else if($typeRecherche==='calendar') { - $fsearch=$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); + $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); } else if($typeRecherche==='calendars') { - $fsearch=$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.'][deb]',isset($value['deb'])?$value['deb']:'',10,10,' listviewtbs="calendars" ') - .' '.$form->calendrier('','TListTBS['.$this->id.'][search]['.$key.'][fin]',isset($value['fin'])?$value['fin']:'',10,10,' listviewtbs="calendars" '); + $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][start]',isset($value['start'])?$value['start']:'',10,10,' listviewtbs="calendars" ') + .' '.$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][end]',isset($value['end'])?$value['end']:'',10,10,' listviewtbs="calendars" '); } else if(is_string($typeRecherche)) { $fsearch=$TParam['search'][$key]; } else { - $fsearch=$form->texte('','TListTBS['.$this->id.'][search]['.$key.']',$value,15,255,' listviewtbs="input" '); + $fsearch=$form->texte('','Listview['.$this->id.'][search]['.$key.']',$value,15,255,' listviewtbs="input" '); } if(!empty($param_search['allow_is_null'])) { - $valueNull = isset($_REQUEST['TListTBS'][$this->id]['search_on_null'][$key]) ? 1 : 0; - $fsearch.=' '.$form->checkbox1('', 'TListTBS['.$this->id.'][search_on_null]['.$key.']',1, $valueNull,' onclick=" if($(this).is(\':checked\')){ $(this).prev().val(\'\'); }" ').img_help(1, $langs->trans('SearchOnNUllValue')); + $valueNull = isset($_REQUEST['Listview'][$this->id]['search_on_null'][$key]) ? 1 : 0; + $fsearch.=' '.$form->checkbox1('', 'Listview['.$this->id.'][search_on_null]['.$key.']',1, $valueNull,' onclick=" if($(this).is(\':checked\')){ $(this).prev().val(\'\'); }" ').img_help(1, $langs->trans('SearchOnNUllValue')); } @@ -342,7 +339,7 @@ class Listview { } - $search_button = ' '.$TParam['liste']['picto_search'].''; + $search_button = ' '.$TParam['liste']['picto_search'].''; if(!empty($TParam['liste']['head_search'])) { $TParam['liste']['head_search'].='
'.$langs->trans('Search').' '.$search_button.'
'; @@ -519,22 +516,77 @@ class Listview { $TExport=$this->setExport($TParam, $TField, $THeader); $TField = $this->addTotalGroup($TField,$TTotalGroup); - var_dump( - array( - 'entete'=>$THeader - ,'champs'=>$TField - ,'recherche'=>$TSearch - ,'total'=>$TTotal - ,'export'=>$TExport - ) - , array( - 'liste'=>array_merge(array('haveExport'=>count($TExport), 'id'=>$this->id, 'nb_columns'=>count($THeader) ,'totalNB'=>count($TField), 'nbSearch'=>count($TSearch), 'haveTotal'=>(int)!empty($TTotal), 'havePage'=>(int)!empty($TPagination) ), $TParam['liste']) - ) - , $TPagination - - ); + $out = $javaScript; - $javaScript; + $out.=load_fiche_titre($TParam['list']['title']); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, count($TField), 'title_products.png', 0, '', '', $limit); + /* + $out.=' + + [onshow;block=begin; when [liste.noheader]==0] + + + [onshow;block=end] + + +
+ [liste.image;magnet=img; strconv=no] +
[liste.titre; strconv=no]
+ +
+ + + + + + + + + + + [onshow;block=tr;when [liste.nbSearch]+-0] + + + + + + + + + + + + + + + + + [onshow;block=tr; when [liste.haveTotal]+-0 ] + + + + +
[liste.head_search;strconv=no;magnet=tr]
[entete.libelle;block=th;strconv=no] + [onshow;block=span; when [entete.order]==1][liste.order_down;strconv=no][liste.order_up;strconv=no] + [entete.more;strconv=no;] +
[recherche.val;block=td;strconv=no]
[champs_sub1.val;block=td; strconv=no]
[champs_sub1.val;block=td; strconv=no]
[total.val;block=td;strconv=no;frm=0 000,00]
+ +
+ [onshow;block=div; when [liste.haveExport]+-0 ] + [export.label;block=a;] +
+

+ [liste.messageNothing;strconv=no] [onshow; block=p; when [liste.totalNB]==0] +

';*/ } public function renderArray(&$db,$TField, $TParam=array()) { @@ -611,14 +663,14 @@ class Listview { global $user; $contextpage=md5($_SERVER['PHP_SELF']); - if((float)DOL_VERSION>=4.0 && empty($TParam['no-select'])) { + if(empty($TParam['no-select'])) { dol_include_once('/core/class/html.form.class.php'); global $db,$conf,$user; $form=new Form($db); - $selectedfields = GETPOST('TListTBS_'.$this->id.'_selectedfields'); + $selectedfields = GETPOST('Listview'.$this->id.'_selectedfields'); if(!empty($selectedfields)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -662,7 +714,7 @@ class Listview { } } - $selectedfields=$form->multiSelectArrayWithCheckbox('TListTBS_'.$this->id.'_selectedfields', $TFieldVisibility, $contextpage); // This also change content of $arrayfields_0 + $selectedfields=$form->multiSelectArrayWithCheckbox('Listview'.$this->id.'_selectedfields', $TFieldVisibility, $contextpage); // This also change content of $arrayfields_0 } @@ -721,17 +773,6 @@ class Listview { else $value=(string)$value; } - if(isset($TParam['subQuery'][$field])) { - $dbSub = new TPDOdb; //TODO finish it - $dbSub->Execute( strtr($TParam['subQuery'][$field], array_merge( $trans, array('@val@'=>$value) )) ); - $subResult = ''; - while($dbSub->Get_line()) { - $subResult.= implode(', ',$dbSub->currentLine).'
'; - } - $value=$subResult; - $dbSub->close(); - } - $trans['@'.$field.'@'] = $value; if(!empty($TParam['math'][$field])) { diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index d092a876ad2..59ad70cec4e 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -87,7 +87,8 @@ class Inventory extends CoreObject function sort_det() { - usort($this->Inventorydet, array('Inventory', 'customSort')); + + if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort')); } function fetch($id,$annexe = true) @@ -99,8 +100,12 @@ class Inventory extends CoreObject $this->sort_det(); $this->amount = 0; - foreach($this->Inventorydet as &$det){ - $this->amount+=$det->qty_view * $det->pmp; + + if(!empty($this->Inventorydet )) { + foreach($this->Inventorydet as &$det){ + $this->amount+=$det->qty_view * $det->pmp; + } + } return $res; From a636d27ccbfc1e5ea59862af1d7e909b382ffff7 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Wed, 14 Dec 2016 14:34:12 +0100 Subject: [PATCH 006/172] Div --- htdocs/core/class/coreobject.class.php | 22 +- htdocs/core/class/listview.class.php | 144 ++-- htdocs/core/lib/functions.lib.php | 114 ++- htdocs/inventory/class/inventory.class.php | 24 +- htdocs/inventory/img/inventory.png | Bin 0 -> 1802 bytes htdocs/inventory/inventory.php | 797 +++++++++++++++++++++ htdocs/inventory/lib/inventory.lib.php | 245 +++++++ htdocs/inventory/tpl/inventory.tpl.php | 211 ++++++ 8 files changed, 1433 insertions(+), 124 deletions(-) create mode 100644 htdocs/inventory/img/inventory.png create mode 100644 htdocs/inventory/inventory.php create mode 100644 htdocs/inventory/lib/inventory.lib.php create mode 100644 htdocs/inventory/tpl/inventory.tpl.php diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 96cbbb89a88..b7e4b2770e3 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -1,5 +1,7 @@ +/* EXPERIMENTAL + * + * Copyright (C) 2016 ATM Consulting * * 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 @@ -220,9 +222,8 @@ class CoreObject extends CommonObject { WHERE rowid='.$id; $res = $this->db->query( $sql ); - if($obj = $this->db->fetch_object($res)) { - $this->rowid=$id; + $this->id=$id; $this->set_vars_by_db($obj); @@ -248,12 +249,12 @@ class CoreObject extends CommonObject { $this->{$className}=array(); - $sql = " SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element."=".$this->rowid; + $sql = " SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element."=".$this->id; $res = $this->db->query($sql); if($res) { - - while($obj = $db->fetch_object($res)) { + $Tab=array(); + while($obj = $this->db->fetch_object($res)) { $o=new $className($this->db); $o->fetch($obj->rowid); @@ -282,5 +283,14 @@ class CoreObject extends CommonObject { } + public function get_date($field,$format='') { + if(empty($this->{$field})) return ''; + elseif($this->{$field}<=strtotime('1000-01-01 00:00:00')) return ''; + else { + return dol_print_date($this->{$field}, $format); + } + + } + } diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index db66f9f15a3..e94a648ec27 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -1,7 +1,8 @@ + Copyright (C) 2016 ATM Consulting This program and all files within this directory and sub directory is free software: you can redistribute it and/or modify it under @@ -505,88 +506,91 @@ class Listview { } private function renderList(&$THeader, &$TField, &$TTotal,&$TTotalGroup, &$TParam) { - + $javaScript = $this->getJS($TParam); - $TPagination=array( + /*$TPagination=array( 'pagination'=>array('pageSize'=>$TParam['limit']['nbLine'], 'pageNum'=>$TParam['limit']['page'], 'blockName'=>'champs', 'totalNB'=>count($TField)) - ); + );*/ $TSearch = $this->setSearch($THeader, $TParam); $TExport=$this->setExport($TParam, $TField, $THeader); $TField = $this->addTotalGroup($TField,$TTotalGroup); $out = $javaScript; + $out.=load_fiche_titre($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $TParam['limit']['page'], count($TField), 'title_products.png', 0, '', '', $limit); + $out.=' + '; - $out.=load_fiche_titre($TParam['list']['title']); - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, count($TField), 'title_products.png', 0, '', '', $limit); - /* - $out.='
- - [onshow;block=begin; when [liste.noheader]==0] - - - [onshow;block=end] - - -
- [liste.image;magnet=img; strconv=no] -
[liste.titre; strconv=no]
- -
+ if(!empty($TParam['liste']['head_search'])) { + $out.=' + '.$TParam['liste']['head_search'].' + '; + } + + $out.=''; - - - - - - - - + foreach($THeader as $head) { + $out.=''; + } + + $out.=''; + + if(!empty($TParam['liste']['nbSearch'])) { + $out.=' + + '; + } - [onshow;block=tr;when [liste.nbSearch]+-0] - - - - - - - - - - - - - - - - - [onshow;block=tr; when [liste.haveTotal]+-0 ] - - - - -
[liste.head_search;strconv=no;magnet=tr]
[entete.libelle;block=th;strconv=no] - [onshow;block=span; when [entete.order]==1][liste.order_down;strconv=no][liste.order_up;strconv=no] - [entete.more;strconv=no;] -
'.$head['libelle']; + + if($head['order']) $out.='[onshow;block=span; when [entete.order]==1]'.img_down().' + '.img_up().''; + + $out.=$head['more']; + $out.='
'.img_search().'
[recherche.val;block=td;strconv=no]
[champs_sub1.val;block=td; strconv=no]
[champs_sub1.val;block=td; strconv=no]
[total.val;block=td;strconv=no;frm=0 000,00]
+ $out.=''; -
- [onshow;block=div; when [liste.haveExport]+-0 ] - [export.label;block=a;] -
-

- [liste.messageNothing;strconv=no] [onshow; block=p; when [liste.totalNB]==0] -

';*/ + $class='pair'; + + if(empty($TField)) { + $out.=' + '.$TParam['liste']['messageNothing'].''; + + } + else{ + + foreach($TField as $fields) { //TODO pagination limit + + $class = ($class=='pair') ? 'impair' : 'pair'; + $out.=' '; + + foreach($fields as $field=>$value) { + $out.=''.$value.''; + } + + $out.=''; + + } + + $out.=''; + + if(!empty($TParam['liste']['haveTotal'])) { + $out.=' + '; + + foreach($TTotal as $field=>$total) { + $out.=''.price($total).''; + } + + $out.=''; + } + + } + + + $out.=''; + + return $out; } public function renderArray(&$db,$TField, $TParam=array()) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 082177b5cbc..c4b21e4ee82 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3157,7 +3157,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', } /** - * Print a title with navigation controls for pagination + * return a title with navigation controls for pagination * * @param string $titre Title to show (required) * @param int $page Numero of page to show in navigation links (required) @@ -3176,7 +3176,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', * @param int $hideselectlimit Force to hide select limit * @return void */ -function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) +function load_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) { global $conf,$langs; @@ -3196,27 +3196,26 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $nextpage = 0; } //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage; - - print "\n"; - print "\n"; - print ''; + $out = "\n"; + $out.= "\n"; + $out.='
'; // Left - //if ($picto && $titre) print ''; - print ''; + //if ($picto && $titre) $out.=''; + $out.=''; // Center if ($center) { - print ''; + $out.=''; } // Right - print ''; + $out.=load_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtml, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist + $out.=''; - print '
'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).''; - if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); - print '
'.$titre; - if (!empty($titre) && $savtotalnboflines >= 0) print ' ('.$totalnboflines.')'; - print '
'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).''; + if ($picto && $titre) $out.=img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); + $out.='
'.$titre; + if (!empty($titre) && $savtotalnboflines >= 0) $out.=' ('.$totalnboflines.')'; + $out.='
'.$center.''.$center.''; + $out.=''; if ($sortfield) $options .= "&sortfield=".$sortfield; if ($sortorder) $options .= "&sortorder=".$sortorder; // Show navigation bar @@ -3265,15 +3264,39 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $pagelist.= 'dol_use_jmobile != 4)?' class="pagination"':'').'>dol_use_jmobile != 4)?'class="active"':'data-role="button"').'>'.($page+1).""; } } - print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtml, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist - print '
'."\n"; - print "\n\n"; + $out.=''."\n"; + $out.="\n\n"; +} +/** + * Print a title with navigation controls for pagination + * + * @param string $titre Title to show (required) + * @param int $page Numero of page to show in navigation links (required) + * @param string $file Url of page (required) + * @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder) + * @param string $sortfield Field to sort on ('' by default) + * @param string $sortorder Order to sort ('' by default) + * @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction() + * @param int $num Number of records found by select with limit+1 + * @param int $totalnboflines Total number of records/lines for all pages (if known). Use a negative value to not show number. + * @param string $picto Icon to use before title (should be a 32x32 transparent png file) + * @param int $pictoisfullpath 1=Icon name is a full absolute url of image + * @param string $morehtml More html to show + * @param string $morecss More css to the table + * @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). + * @param int $hideselectlimit Force to hide select limit + * @return void + */ +function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) +{ + echo load_barre_liste($titre, $page, $file, $options, $sortfield, $sortorder, $center, $num, $totalnboflines, $picto, $pictoisfullpath, $morehtml, $morecss, $limit, $hideselectlimit); } /** - * Function to show navigation arrows into lists + * Function to return navigation arrows into lists * * @param int $page Number of page * @param string $file Page URL (in most cases provided with $_SERVER["PHP_SELF"]) @@ -3286,11 +3309,11 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so * @param int $hideselectlimit Force to hide select limit * @return void */ -function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0) +function load_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0) { global $conf, $langs; - print ''."\n"; +} +/** + * Function to show navigation arrows into lists + * + * @param int $page Number of page + * @param string $file Page URL (in most cases provided with $_SERVER["PHP_SELF"]) + * @param string $options Other url paramaters to propagate ("" by default, may include sortfield and sortorder) + * @param integer $nextpage Do we show a next page button + * @param string $betweenarrows HTML content to show between arrows. MUST contains '
  • ' tags or '
  • '. + * @param string $afterarrows HTML content to show after arrows. Must NOT contains '
  • ' tags. + * @param int $limit Max nb of record to show (-1 = no combo with limit, 0 = no limit, > 0 = limit) + * @param int $totalnboflines Total number of records/lines for all pages (if known) + * @param int $hideselectlimit Force to hide select limit + * @return void + */ +function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0) +{ + echo load_fleche_navigation($page, $file, $options, $nextpage, $betweenarrows, $afterarrows, $limit, $totalnboflines, $hideselectlimit); } - /** * Return a string with VAT rate label formated for view output diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 59ad70cec4e..2a485d24a0a 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -97,17 +97,20 @@ class Inventory extends CoreObject if(!$annexe) $this->withChild = false; $res = parent::fetch($id); - $this->sort_det(); - $this->amount = 0; - - if(!empty($this->Inventorydet )) { - foreach($this->Inventorydet as &$det){ - $this->amount+=$det->qty_view * $det->pmp; - } + if($res>0) { + $this->sort_det(); + $this->amount = 0; + + if(!empty($this->Inventorydet )) { + foreach($this->Inventorydet as &$det){ + $this->amount+=$det->qty_view * $det->pmp; + } + + } } - + return $res; } @@ -312,9 +315,8 @@ class Inventory extends CoreObject global $langs,$db; $i = new Inventory($db); - $i->fetch($id, false); - - return $i->getNomUrl(); + if($i->fetch($id, false)>0) return $i->getNomUrl(); + else return $langs->trans('InventoryUnableToFetchObject'); } diff --git a/htdocs/inventory/img/inventory.png b/htdocs/inventory/img/inventory.png new file mode 100644 index 0000000000000000000000000000000000000000..e54ad0eef7d76b373e8769153f9039a75681ab3b GIT binary patch literal 1802 zcmZ{lX*3(?9>&822~viNsg4qwu~r48mJ=dMOk>Y2Wo%QL#J&qgL@l*c2PvXOtG0v| z4HeOr1QSB3-7rPaP%cHabz5~!I^XVx`~KhO|2yw<&hza#=goC>c7RB$NCN->h$F_% zT}1V70!fN?Y;y7k5rBA<6AA#B1HNX?i;Lcpzg~8*0~~*w2QM0^A_p9Wxf&}X<{#Pf zLy_OigeVkVMD>4k^GijgD5~jbhr)UFO?witIQ+@fjF~H?I=(pFT357=t^NZij3WFj zFYi*ZDNk*}F1=R8%p{L^x47^pp%luFfIw(t>h!td?kG@`R{#YB!ivq=Nfrj%T+I%a zjChs0Jcq(_7*6-de11yg^~Jw;gFK?Q}3f4MRkp824f@t zrkvVOaR~`kL?UsIop#*qk(9)q{v%&`WMXpiIH_i~*;lc*uP?Z~ynM~!_cN)i?r!AX z-s*sfp`lG`YU<<*uZ4w$L^Ugt{L<^!zjf8uueGhLtjKw|yDvIpv3FKe&HYb-!Ql5z zo-ISmDBeAi-?Ox1^70!#l?Se^ub0+xt{^ovHR+L~qFN<+%c&R6aR)&K05lq%xpP5% zHh*bGTq&EfwEHiy-lE&LZ-*Xi&0VXoiHTtfR#)4=K$V7uhTQ6L0>;=FeV3tgSG*su z$l2LNg7Ct33(r(9w%dEUxfKb7LgCcn;-VE2=?sBDrfPBSXumTI3V+;<3O1wxVu;dy zHvM_lO7e1Z!r`*uy}dnqu&kWiWaUfj=IG#qi3jSNEiK2xnrRt;bp;Il{4brYo^(3> z;?djj8e>-E5_z3haQe#h^fVL>hhGM(j|#K0rsSdapNoo2D6}5kbRLg)#ovF)C6h*@ z`Ma%q#K*_yr5wBy_L8tfBEy(@d@7yKcMJ&+uY+a^`4=VzW4(g5+`B24%hMN{$UG!&<3#Oc$YSWcT#vb6^ zK=tcgIXNI``Yeqi+uFfo&d0wUtM)fCGUBBK$mW`XT25-}*K9F0NObn|iaeLfhkiJ& z>&VHr(ZGxv=sKv-W~cPYz+29g8D<(uY** zk~EP848cK2Xy{+8h=t7vjMSfSwTqUPX{u1@70BaR6uX~RQd%;;uob2&QS{^qf(pi* z5gax)HinR1FAKOCk{1SLz3}1TN1vZu8;B_^v>^l9;`h9CGx_ath8jtFEr@ zF^k1=gPlajycsN7)#hI%h*uxxp5-Z1U7Ds17_#UwYj*AFd>|PwZke#<)d3qCo9jlO zDEzrj0|!F2(|daES0Ph%6E2zldTVfBYj#IMPa!HXaeeso#iRIkzi7>Oq>_>noU5x% zVYoB|5{&rXY-%G;oh-*wDdgXlnvK$P?9vM zHqsuwYCq44R1=kFTw7)G>({R`z$&xRyhfLR!%y4U-~dgSsp$;F=+O#we{Dj?TuRgm zP_W&fnO0U-ASKQ0+_Y;sl%NXk0Z8~B*oj1ZN6vL>_z1=bMwV6I9~@})7l(y~ft1i& z=iC}U-nwkAUL+8coOFl2e8g&NGcHUra;pf+Ibc1nMv8U+EWrQwOqGU~mR2tXwwZ+# zGu16x!#8VSy(^oWo5k{b4_0DgV-*$UGuGqD>0o`)K^UZ4<1@A(Sl2sLDq4Saf?roG zr0yf%p6>(AnQuk1=w|1e>2z(e<^{lkXY9l|2b=q#)3&2ICFwH;D#GttLt@~81h{N1 ze0SHuux*I2r^y8d9URi6j9d?OW%az@WD@%2KPcWoAP}%mDc#KL0rf!}!V{Q5y$Eh; z=**+5(Yh>P2dsnZ%0YSuI@*00E_7^7W+t=}U~28r(a{4>b~ejC`*6xTRe&9+?0eDD z;SLT1k6@hbwjaEIi0$;};8#9mdMl&3NgSDNU)3Lf+^Si+QRYh~lW(xupHmDB3>pfb zA{2JR^D|(RXnzYg&)}|wV>r|n~!*{-=s((QAPs}89mf@}7sI@T| z@7dP&c8@LVaBX+FFM51@yeF_L&tArFXJdo-zQ?3I*Xt>!VxOS;N|`f2(cJx#_EGAu zmtGr3VC=0Ono$eIRP=Aa<1Tr{1qH?hTU?6?76D*nXlQ;;bP>ilgt3K@sfCHDo}rP2 kp`jGvVekJ0!Xtx-*OUH#AmM@vSrh;`UUIf;whg%PHyWxmfdBvi literal 0 HcmV?d00001 diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php new file mode 100644 index 00000000000..d46f05059b4 --- /dev/null +++ b/htdocs/inventory/inventory.php @@ -0,0 +1,797 @@ + + * + * 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/inventory/inventory.php + * \ingroup product + * \brief File of class to manage inventory + */ + +require_once '../main.inc.php'; + +ini_set('memory_limit', '512M'); + +require_once DOL_DOCUMENT_ROOT.'/core/class/listview.class.php'; +require_once DOL_DOCUMENT_ROOT.'/inventory/class/inventory.class.php'; +require_once DOL_DOCUMENT_ROOT.'/inventory/lib/inventory.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + +set_time_limit(0); + +if(!$user->rights->inventory->read) accessforbidden(); + +$langs->load("inventory"); + +_action(); + +function _action() +{ + global $user, $db, $conf, $langs; + + /******************************************************************* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + ********************************************************************/ + + $action=GETPOST('action'); + + switch($action) { + case 'list': + _list(); + + break; + + case 'create': + if (!$user->rights->inventory->create) accessforbidden(); + + $inventory = new Inventory($db); + + _fiche_warehouse($user, $db, $conf, $langs, $inventory); + + break; + + case 'confirmCreate': + if (!$user->rights->inventory->create) accessforbidden(); + + + $inventory = new Inventory($db); + $inventory->set_values($_REQUEST); + + $fk_inventory = $inventory->save(); + $fk_category = (int)GETPOST('fk_category'); + $fk_supplier = (int)GETPOST('fk_supplier'); + $fk_warehouse = (int)GETPOST('fk_warehouse'); + $only_prods_in_stock = (int)GETPOST('OnlyProdsInStock'); + + $e = new Entrepot($db); + $e->fetch($fk_warehouse); + $TChildWarehouses = array($fk_warehouse); + if(method_exists($e, 'get_children_warehouses')) $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); + + $sql = 'SELECT ps.fk_product, ps.fk_entrepot + FROM '.MAIN_DB_PREFIX.'product_stock ps + INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product) + LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid) + LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid) + WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')'; + + if($fk_category>0) $sql.= " AND cp.fk_categorie=".$fk_category; + if($fk_supplier>0) $sql.= " AND pfp.fk_soc=".$fk_supplier; + if($only_prods_in_stock>0) $sql.= ' AND ps.reel > 0'; + + $sql.=' GROUP BY ps.fk_product, ps.fk_entrepot + ORDER BY p.ref ASC,p.label ASC'; + + + $Tab = $PDOdb->ExecuteAsArray($sql); + + foreach($Tab as &$row) { + + $inventory->add_product($PDOdb, $row->fk_product, $row->fk_entrepot); + } + + $inventory->save($PDOdb); + + header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->getId().'&action=edit', 1)); + + case 'edit': + if (!$user->rights->inventory->write) accessforbidden(); + + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, __get('action', 'edit', 'string')); + + break; + + case 'save': + if (!$user->rights->inventory->write) accessforbidden(); + + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + $inventory->set_values($_REQUEST); + + if ($inventory->errors) + { + setEventMessage($inventory->errors, 'errors'); + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + } + else + { + $inventory->save($PDOdb); + header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->getId().'&action=view', 1)); + } + + break; + + case 'regulate': + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + if($inventory->status == 0) { + $inventory->status = 1; + $inventory->save($PDOdb); + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + + + } + else { + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + } + + break; + + case 'changePMP': + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + $inventory->changePMP($PDOdb); + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + + break; + + case 'add_line': + if (!$user->rights->inventory->write) accessforbidden(); + + + $id = __get('id', 0, 'int'); + $fk_warehouse = __get('fk_warehouse', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + $type = (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) ? 'string' : 'int'); //AA heu ? + + $fk_product = __get('fk_product', 0, $type); + + if ($fk_product) + { + $product = new Product($db); + $product->fetch($fk_product); // ! ref TODO vérifier quand même + if($product->type != 0) { + setEventMessage($langs->trans('ThisIsNotAProduct'),'errors'); + } + else{ + + //Check product not already exists + $alreadyExists = false; + foreach ($inventory->Inventorydet as $invdet) + { + if ($invdet->fk_product == $product->id + && $invdet->fk_warehouse == $fk_warehouse) + { + $alreadyExists = true; + break; + } + } + + if (!$alreadyExists) + { + $inventory->add_product($PDOdb, $product->id, $fk_warehouse); + + } + else + { + setEventMessage($langs->trans('inventoryWarningProductAlreadyExists'), 'warnings'); + } + + } + + $inventory->save($PDOdb); + $inventory->sort_det(); + } + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + + break; + + case 'delete_line': + if (!$user->rights->inventory->write) accessforbidden(); + + + //Cette action devrais se faire uniquement si le status de l'inventaire est à 0 mais aucune vérif + $rowid = __get('rowid', 0, 'int'); + $Inventorydet = new Inventory($db); + $Inventorydet->load($PDOdb, $rowid); + $Inventorydet->delete($PDOdb); + + $id = __get('id', 0, 'int'); + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + + break; + case 'flush': + if (!$user->rights->inventory->create) accessforbidden(); + + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + $inventory->deleteAllLine($PDOdb); + + setEventMessage('Inventaire vidé'); + + _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + + + break; + case 'delete': + if (!$user->rights->inventory->create) accessforbidden(); + + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + $inventory->delete($PDOdb); + + header('Location: '.dol_buildpath('/inventory/inventory.php', 1)); + exit; + //_list(); + + case 'printDoc': + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + generateODT($PDOdb, $db, $conf, $langs, $inventory); + break; + + case 'exportCSV': + + $id = __get('id', 0, 'int'); + + $inventory = new Inventory($db); + $inventory->load($PDOdb, $id); + + exportCSV($inventory); + + exit; + break; + + default: + if (!$user->rights->inventory->write) accessforbidden(); + + $id = GETPOST('id'); + + $inventory = new Inventory($db); + $inventory->fetch($id); + + _card($inventory, $action ); + + + break; + } + +} + +function _list() +{ + + global $db, $conf, $langs, $user; + + llxHeader('',$langs->trans('inventoryListTitle'),'',''); + + $inventory = new Inventory($db); + $l = new ListView($db,'listInventory'); + + $THide = array('label'); + + echo $l->render(Inventory::getSQL('All'), array( + 'limit'=>array( + 'nbLine'=>'30' + ) + ,'subQuery'=>array() + ,'link'=>array( + 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' + ) + ,'translate'=>array() + ,'hide'=>$THide + ,'type'=>array( + 'date_cre'=>'date' + ,'date_maj'=>'datetime' + ,'date_inventory'=>'date' + ) + ,'liste'=>array( + 'titre'=>$langs->trans('inventoryListTitle') + ,'image'=>img_picto('','title.png', '', 0) + ,'picto_precedent'=>img_picto('','back.png', '', 0) + ,'picto_suivant'=>img_picto('','next.png', '', 0) + ,'noheader'=> (int)isset($_REQUEST['fk_soc']) | (int)isset($_REQUEST['fk_product']) + ,'messageNothing'=>$langs->trans('inventoryListEmpty') + ,'picto_search'=>img_picto('','search.png', '', 0) + ) + ,'title'=>array( + 'rowid'=>$langs->trans('Title') + ,'fk_warehouse'=>$langs->trans('Warehouse') + ,'date_inventory'=>$langs->trans('InventoryDate') + ,'datec'=>$langs->trans('DateCreation') + ,'tms'=>$langs->trans('DateUpdate') + ,'status'=>$langs->trans('Status') + ) + ,'eval'=>array( + 'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))' + ,'rowid'=>'Inventory::getLink(@val@)' + + ) + )); + + + if ($user->rights->inventory->create) + { + print '
    '; + print ''.$langs->trans('inventoryCreate').''; + print '
    '; + } + + llxFooter(''); +} + +function _fiche_warehouse(&$PDOdb, &$user, &$db, &$conf, $langs, $inventory) +{ + dol_include_once('/categories/class/categorie.class.php'); + + llxHeader('',$langs->trans('inventorySelectWarehouse'),'',''); + print dol_get_fiche_head(inventoryPrepareHead($inventory)); + + $form=new TFormCore('inventory.php', 'confirmCreate'); + print $form->hidden('action', 'confirmCreate'); + $form->Set_typeaff('edit'); + + $formproduct = new FormProduct($db); + $formDoli = new Form($db); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    trans('Title') ?>texte('', 'title', '',50,255) ?>
    trans('Date') ?>calendrier('', 'date_inventory',time()) ?>
    trans('inventorySelectWarehouse') ?>selectWarehouses('', 'fk_warehouse') ?>
    trans('SelectCategory') ?>select_all_categories(0,'', 'fk_category') ?>
    trans('SelectFournisseur') ?>select_thirdparty('','fk_supplier','s.fournisseur = 1') ?>
    trans('OnlyProdsInStock') ?>
    + '; + print ''; + print ''; + + print $form->end_form(); + llxFooter(''); +} + +function _card(&$inventory, $mode='edit') +{ + global $langs, $conf, $db, $user; + + llxHeader('',$langs->trans('inventoryEdit'),'',''); + + $warehouse = new Entrepot($db); + $warehouse->fetch($inventory->fk_warehouse); + + print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), '&action='.$mode)); + + $lines = array(); + _card_line($inventory, $lines, $form); + + print ''.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'

    '; + + $inventoryTPL = array( + 'id'=> $inventory->id + ,'date_cre' => $inventory->get_date('date_cre', 'd/m/Y') + ,'date_maj' => $inventory->get_date('date_maj', 'd/m/Y H:i') + ,'fk_warehouse' => $inventory->fk_warehouse + ,'status' => $inventory->status + ,'entity' => $inventory->entity + ,'amount' => price( round($inventory->amount,2) ) + ,'amount_actual'=>price (round($inventory->amount_actual,2)) + + ); + + $can_validate = !empty($user->rights->inventory->validate); + $view_url = dol_buildpath('/inventory/inventory.php', 1); + + $view = array( + 'mode' => $mode + ,'url' => dol_buildpath('/inventory/inventory.php', 1) + ,'can_validate' => (int) $user->rights->inventory->validate + ,'is_already_validate' => (int) $inventory->status + ,'token'=>$_SESSION['newtoken'] + ); + + include './tpl/inventory.tpl.php'; + + llxFooter(''); +} + + +function _card_line(&$inventory, &$lines, &$form) +{ + global $db; + $inventory->amount_actual = 0; + + $TCacheEntrepot = array(); + + foreach ($inventory->Inventorydet as $k => $Inventorydet) + { + + $product = & $Inventorydet->product; + $stock = $Inventorydet->qty_stock; + + $pmp = $Inventorydet->pmp; + $pmp_actual = $pmp * $stock; + $inventory->amount_actual+=$pmp_actual; + + $last_pa = $Inventorydet->pa; + $current_pa = $Inventorydet->current_pa; + + $e = new Entrepot($db); + if(!empty($TCacheEntrepot[$Inventorydet->fk_warehouse])) $e = $TCacheEntrepot[$Inventorydet->fk_warehouse]; + elseif($e->fetch($Inventorydet->fk_warehouse) > 0) $TCacheEntrepot[$e->id] = $e; + + $lines[]=array( + 'produit' => $product->getNomUrl(1).' - '.$product->label + ,'entrepot'=>$e->getNomUrl(1) + ,'barcode' => $product->barcode + /*,'qty' => $form->texte('', 'qty_to_add['.$k.']', (isset($_REQUEST['qty_to_add'][$k]) ? $_REQUEST['qty_to_add'][$k] : 0), 8, 0, "style='text-align:center;'") + .($form->type_aff!='view' ? ''.img_picto('Ajouter', 'plus16@inventory').'' : '') + ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 + ,'qty_stock' => $stock + ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 + ,'action' => $user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '' + ,'pmp_stock'=>round($pmp_actual,2) + ,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) + ,'pmp_new'=>(!empty($user->rights->inventory->changePMP) ? $form->texte('', 'new_pmp['.$k.']',$Inventorydet->new_pmp, 8, 0, "style='text-align:right;'") + .($form->type_aff!='view' ? ''.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : '') : '' ) + */,'pa_stock'=>round($last_pa * $stock,2) + ,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) + ,'current_pa_stock'=>round($current_pa * $stock,2) + ,'current_pa_actual'=>round($current_pa * $Inventorydet->qty_view,2) + + ,'k'=>$k + ,'id'=>$Inventorydet->id + + ); + } + +} + +function exportCSV(&$inventory) { + global $conf; + + header('Content-Type: application/octet-stream'); + header('Content-disposition: attachment; filename=inventory-'. $inventory->getId().'-'.date('Ymd-His').'.csv'); + header('Pragma: no-cache'); + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + header('Expires: 0'); + + echo 'Ref;Label;barcode;qty theorique;PMP;dernier PA;'; + if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) echo 'PA courant;'; + echo 'qty réelle;PMP;dernier PA;'; + if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) echo 'PA courant;'; + echo 'qty regulée;'."\r\n"; + + foreach ($inventory->Inventorydet as $k => $Inventorydet) + { + $product = & $Inventorydet->product; + $stock = $Inventorydet->qty_stock; + + $pmp = $Inventorydet->pmp; + $pmp_actual = $pmp * $stock; + $inventory->amount_actual+=$pmp_actual; + + $last_pa = $Inventorydet->pa; + $current_pa = $Inventorydet->current_pa; + + if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) { + $row=array( + 'produit' => $product->ref + ,'label'=>$product->label + ,'barcode' => $product->barcode + ,'qty_stock' => $stock + ,'pmp_stock'=>round($pmp_actual,2) + ,'pa_stock'=>round($last_pa * $stock,2) + ,'current_pa_stock'=>round($current_pa * $stock,2) + ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 + ,'pmp_actual'=>round($pmp * $Inventorydet->qty_view,2) + ,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) + ,'current_pa_actual'=>round($current_pa * $Inventorydet->qty_view,2) + ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 + + ); + + } + else{ + $row=array( + 'produit' => $product->ref + ,'label'=>$product->label + ,'barcode' => $product->barcode + ,'qty_stock' => $stock + ,'pmp_stock'=>round($pmp_actual,2) + ,'pa_stock'=>round($last_pa * $stock,2) + ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 + ,'pmp_actual'=>round($pmp * $Inventorydet->qty_view,2) + ,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) + + ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 + + ); + + } + + + echo '"'.implode('";"', $row).'"'."\r\n"; + + } + + exit; +} + +function generateODT(&$PDOdb, &$db, &$conf, &$langs, &$inventory) +{ + $TBS=new TTemplateTBS(); + + $InventoryPrint = array(); // Tableau envoyé à la fonction render contenant les informations concernant l'inventaire + + foreach($inventory->Inventorydet as $k => $v) + { + $prod = new Product($db); + $prod->fetch($v->fk_product); + //$prod->fetch_optionals($prod->id); + + $InventoryPrint[] = array( + 'product' => $prod->ref.' - '.$prod->label + , 'qty_view' => $v->qty_view + ); + } + + $warehouse = new Entrepot($db); + $warehouse->fetch($inventory->fk_warehouse); + + $dirName = 'INVENTORY'.$inventory->getId().'('.date("d_m_Y").')'; + $dir = DOL_DATA_ROOT.'/inventory/'.$dirName.'/'; + + @mkdir($dir, 0777, true); + + $template = "templateINVENTORY.odt"; + //$template = "templateOF.doc"; + + $file_gen = $TBS->render(dol_buildpath('inventory/exempleTemplate/'.$template) + ,array( + 'InventoryPrint'=>$InventoryPrint + ) + ,array( + 'date_cre'=>$inventory->get_date('date_cre', 'd/m/Y') + ,'date_maj'=>$inventory->get_date('date_maj', 'd/m/Y H:i') + ,'date_inv'=>$inventory->get_date('date_inventory', 'd/m/Y') + ,'numero'=>empty($inventory->title) ? 'Inventaire n°'.$inventory->getId() : $inventory->title + ,'warehouse'=>$warehouse->libelle + ,'status'=>($inventory->status ? $langs->transnoentitiesnoconv('inventoryValidate') : $langs->transnoentitiesnoconv('inventoryDraft')) + ,'logo'=>DOL_DATA_ROOT."/mycompany/logos/".MAIN_INFO_SOCIETE_LOGO + ) + ,array() + ,array( + 'outFile'=>$dir.$inventory->getId().".odt" + ,"convertToPDF"=>(!empty($conf->global->INVENTORY_GEN_PDF) ? true : false) + ,'charset'=>OPENTBS_ALREADY_UTF8 + + ) + + ); + + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=inventory&entity=".$conf->entity."&file=".$dirName."/".$inventory->getId(). (!empty($conf->global->INVENTORY_GEN_PDF) ? '.pdf' : '.odt') ); + + /* + $size = filesize("./" . basename($file_gen)); + header("Content-Type: application/force-download; name=\"" . basename($file_gen) . "\""); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: $size"); + header("Content-Disposition: attachment; filename=\"" . basename($file_gen) . "\""); + header("Expires: 0"); + header("Cache-Control: no-cache, must-revalidate"); + header("Pragma: no-cache"); + + readfile($file_gen); + */ + + //header("Location: ".DOL_URL_ROOT."/document.php?modulepart=asset&entity=1&file=".$dirName."/".$assetOf->numero.".doc"); + +} +function _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actual, $total_current_pa,$total_current_pa_actual) { + global $conf,$user,$langs; + + + if ($view['can_validate'] == 1) { ?> + +   + barcode->enabled)) { ?> +   + + + + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo ''.price($total_current_pa).''; + } + ?> +   + + rights->inventory->changePMP)) { + echo ' '; + } + ?> + + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo ''.price($total_current_pa_actual).''; + } + ?> + +   + +   + + + + +   Produit + Entrepôt + barcode->enabled)) { ?> + Code-barre + + + Quantité théorique + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo 'Valeur théorique'; + } + else { + echo 'Valeur théorique'; + } + + ?> + + + Quantité réelle + + + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) $colspan++; + if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) $colspan++; + + echo 'Valeur réelle'; + + ?> + + Quantité régulée + + + # + + + + + +   + PMP + Dernier PA + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo 'PA courant'; + } + + ?> +   + PMP + rights->inventory->changePMP)) { + echo ''.$langs->trans('ColumnNewPMP').''; + } + ?> + Dernier PA + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo 'PA courant'; + } + + ?> +   + +   + + + + * Copyright (C) 2015 ATM Consulting + * + * 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 lib/inventory.lib.php + * \ingroup inventory + * \brief This file is an example module library + * Put some comments here + */ + +function inventoryAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("inventory@inventory"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/inventory/admin/inventory_setup.php", 1); + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'settings'; + $h++; + $head[$h][0] = dol_buildpath("/inventory/admin/inventory_about.php", 1); + $head[$h][1] = $langs->trans("About"); + $head[$h][2] = 'about'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@inventory:/inventory/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@inventory:/inventory/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'inventory'); + + return $head; +} + +function inventoryPrepareHead(&$inventory, $title='Inventaire', $get='') +{ + return array( + array(dol_buildpath('/inventory/inventory.php?id='.$inventory->id.$get, 1), $title,'inventaire') + ); +} + + + +function inventorySelectProducts(&$inventory) +{ + global $conf,$db; + + $except_product_id = array(); + + foreach ($inventory->Inventorydet as $Inventorydet) + { + $except_product_id[] = $Inventorydet->fk_product; + } + + ob_start(); + $form = new Form($db); + $form->select_produits(-1, 'fk_product'); + + // Il nous faut impérativement une liste custom car il ne faut que les entrepôts de la famille de celui qu'on inventorie + $TChildWarehouses = array($inventory->fk_warehouse); + $e = new Entrepot($db); + $e->fetch($inventory->fk_warehouse); + if(method_exists($e, 'get_children_warehouses')) $e->get_children_warehouses($e->id, $TChildWarehouses); + + $Tab = array(); + $sql = 'SELECT rowid, label + FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid IN('.implode(', ', $TChildWarehouses).')'; + if(method_exists($e, 'get_children_warehouses')) $sql.= ' ORDER BY fk_parent'; + $resql = $db->query($sql); + while($res = $db->fetch_object($resql)) { + $Tab[$res->rowid] = $res->label; + } + print '   '; + print 'Entrepôt : '.$form::selectarray('fk_warehouse', $Tab); + + $select_html = ob_get_clean(); + + return $select_html; +} + +function ajaxAutocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array()) +{ + if (empty($minLength)) $minLength=1; + + $script = ''; + + $script.= ''; + + return $script; +} diff --git a/htdocs/inventory/tpl/inventory.tpl.php b/htdocs/inventory/tpl/inventory.tpl.php new file mode 100644 index 00000000000..d7022245f5b --- /dev/null +++ b/htdocs/inventory/tpl/inventory.tpl.php @@ -0,0 +1,211 @@ + + +status != 1) { ?> + trans('AddInventoryProduct'); ?> : +
    + + + + + + +
    + + +
    + + +
    Cet inventaire est validé
    + + + + + + + $row) { + + $total_pmp+=$row['pmp_stock']; + $total_pa+=$row['pa_stock']; + $total_pmp_actual+=$row['pmp_actual']; + $total_pa_actual+=$row['pa_actual']; + + if($i%20 === 0) + { + _headerList($view); + } // Fin IF principal + ?> + + + + barcode->enabled)) { ?> + + + + + + + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo ''; + $total_current_pa+=$row['current_pa_stock']; + } + + ?> + + + + + rights->inventory->changePMP)) { + echo ''; + } + ?> + + global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ + echo ''; + $total_current_pa_actual+=$row['current_pa_actual']; + } + + ?> + + + + + + + + + + + + +
      '.price($row['current_pa_stock']).'   + + '.$row['pmp_new'].''.price($row['current_pa_actual']).'
    + + +
    + + trans('Print') ?> + trans('ExportCSV') ?> + trans('Modify') ?> + rights->inventory->changePMP)) { + echo ''.$langs->trans('ApplyPMP').''; + } + + if ($can_validate == 1) { ?> + Réguler le stock + + + + + + + Vider +     + Supprimer + +
    + + + + +
    +

    Date de création : get_date('datec') ?> +
    Dernière mise à jour : get_date('tms') ?>

    + + + From 565bcf233276535280c86a16f287df1eae7963a5 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Wed, 14 Dec 2016 16:11:37 +0100 Subject: [PATCH 007/172] debug fetch method --- htdocs/core/class/coreobject.class.php | 76 +++++++++-- htdocs/inventory/class/inventory.class.php | 58 ++++----- htdocs/inventory/inventory.php | 145 ++++++--------------- htdocs/inventory/tpl/inventory.tpl.php | 12 +- 4 files changed, 137 insertions(+), 154 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index b7e4b2770e3..f5e5b0e79a1 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -78,14 +78,20 @@ class CoreObject extends CommonObject { } + private function checkFieldType($field, $type) { + + if( isset($this->__fields[$field]) && method_exists($this, 'is_'.$type)) { + return $this->{'is_'.$type}($this->__fields[$field]); + } + else return false; + + } private function is_date(Array &$info){ - if(is_array($info)) { - if(isset($info['type']) && $info['type']=='date') return true; - else return false; - } + if(isset($info['type']) && $info['type']=='date') return true; else return false; + } private function is_array($info) { @@ -239,7 +245,25 @@ class CoreObject extends CommonObject { } } + public function addChild($tabName, $id='', $key='id', $try_to_load = false) { + if(!empty($id)) { + foreach($this->{$tabName} as $k=>&$object) { + if($object->{$key} === $id) return $k; + } + } + + $k = count($this->{$tabName}); + + $className = ucfirst($tabName); + $this->{$tabName}[$k] = new $className($this->db); + if($id>0 && $key==='id' && $try_to_load) { + $this->{$tabName}[$k]->fetch($id); + } + + + return $k; + } public function fetchChild() { if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { @@ -272,13 +296,13 @@ class CoreObject extends CommonObject { } - public function update() { - + public function update(User &$user) { + if(empty($this->id )) return $this->create($user); } - public function create() { - + public function create(User &$user) { + if($this->id>0) return $this->update($user); } @@ -287,10 +311,46 @@ class CoreObject extends CommonObject { if(empty($this->{$field})) return ''; elseif($this->{$field}<=strtotime('1000-01-01 00:00:00')) return ''; else { + return dol_print_date($this->{$field}, $format); } } + public function set_date($field,$date){ + + if(empty($date)) { + $this->{$field} = 0; + } + else { + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $this->{$field} = dol_stringtotime($date); + } + + return $this->{$field}; + } + + public function set_values(&$Tab) { + foreach ($Tab as $key=>$value) { + + if($this->checkFieldType($key,'date')) { + $this->set_date($key, $value); + } + else if( $this->checkFieldType($key,'array')){ + $this->{$key} = $value; + } + else if( $this->checkFieldType($key,'float') ) { + $this->{$key} = (double)price2num($value); + } + else if( $this->checkFieldType($key,'int') ) { + $this->{$key} = (int)price2num($value); + } + else { + $this->{$key} = @stripslashes($value); + } + + } + } } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 2a485d24a0a..f2ff6484c64 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -147,15 +147,16 @@ class Inventory extends CoreObject } - function update() + function update(User &$user) { + //si on valide l'inventaire on sauvegarde le stock à cette instant if ($this->status) { $this->regulate(); } - parent::update(); + parent::update($user); } function set_values($Tab) @@ -209,7 +210,7 @@ class Inventory extends CoreObject $det->load_product(); $date = $this->get_date('date_inventory', 'Y-m-d'); - if(empty($date))$date = $this->get_date('date_cre', 'Y-m-d'); + if(empty($date))$date = $this->get_date('datec', 'Y-m-d'); $det->setStockDate( $date , $fk_entrepot); } @@ -416,9 +417,9 @@ class Inventorydet extends CoreObject return true; } - function setStockDate(&$PDOdb, $date, $fk_warehouse) { + function setStockDate($date, $fk_warehouse) { - list($pmp,$stock) = $this->getPmpStockFromDate($PDOdb, $date, $fk_warehouse); + list($pmp,$stock) = $this->getPmpStockFromDate($date, $fk_warehouse); $this->qty_stock = $stock; $this->pmp = $pmp; @@ -432,18 +433,17 @@ class Inventorydet extends CoreObject AND datem<='".$date." 23:59:59' ORDER BY datem DESC LIMIT 1"; - $res = $db->query($sql); + $res = $this->db->query($sql); - if($obj = $db->fetch_object($res)) { + if($res && $obj = $this->db->fetch_object($res)) { $last_pa = $obj->price; } $this->pa = $last_pa; - /* var_dump($fk_warehouse,$this->product->stock_warehouse,$this->pmp, $this->pa, $this->qty_stock); - exit;*/ + } - function getPmpStockFromDate(&$PDOdb, $date, $fk_warehouse){ + function getPmpStockFromDate( $date, $fk_warehouse){ $res = $this->product->load_stock(); @@ -459,7 +459,7 @@ class Inventorydet extends CoreObject } - //On récupère tous les mouvements de stocks du produit entre aujourd'hui et la date de l'inventaire + //All Stock mouvement between now and inventory date $sql = "SELECT value, price FROM ".MAIN_DB_PREFIX."stock_mouvement WHERE fk_product = ".$this->product->id." @@ -467,31 +467,25 @@ class Inventorydet extends CoreObject AND datem > '".date('Y-m-d 23:59:59',strtotime($date))."' ORDER BY datem DESC"; - //echo $sql.'
    '; - $db->query($sql); - $TMouvementStock = $PDOdb->Get_All(); + + $res = $this->db->query($sql); + $laststock = $stock; $lastpmp = $pmp; - //Pour chacun des mouvements on recalcule le PMP et le stock physique - foreach($TMouvementStock as $mouvement){ - - //150 - //if($this->product->id==394) echo 'laststock = '.$stock.'
    '; - - //9.33 - //if($this->product->id==394) echo 'lastpmp = '.$pmp.'
    '; - $price = ($mouvement->price>0 && $mouvement->value>0) ? $mouvement->price : $lastpmp; + + if($res) { + while($mouvement = $this->db->fetch_object($res)) { + $price = ($mouvement->price>0 && $mouvement->value>0) ? $mouvement->price : $lastpmp; - $stock_value = $laststock * $lastpmp; + $stock_value = $laststock * $lastpmp; + + $laststock -= $mouvement->value; + + $last_stock_value = $stock_value - ($mouvement->value * $price); + + $lastpmp = ($laststock != 0) ? $last_stock_value / $laststock : $lastpmp; + } - $laststock -= $mouvement->value; - - $last_stock_value = $stock_value - ($mouvement->value * $price); - - $lastpmp = ($laststock != 0) ? $last_stock_value / $laststock : $lastpmp; - - - } return array($lastpmp,$laststock); diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index d46f05059b4..4e70ee1b4cc 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -66,18 +66,17 @@ function _action() $inventory = new Inventory($db); - _fiche_warehouse($user, $db, $conf, $langs, $inventory); + _card_warehouse( $inventory); break; case 'confirmCreate': if (!$user->rights->inventory->create) accessforbidden(); - - + $inventory = new Inventory($db); - $inventory->set_values($_REQUEST); + $inventory->set_values($_POST); - $fk_inventory = $inventory->save(); + $fk_inventory = $inventory->create($user); $fk_category = (int)GETPOST('fk_category'); $fk_supplier = (int)GETPOST('fk_supplier'); $fk_warehouse = (int)GETPOST('fk_warehouse'); @@ -86,7 +85,7 @@ function _action() $e = new Entrepot($db); $e->fetch($fk_warehouse); $TChildWarehouses = array($fk_warehouse); - if(method_exists($e, 'get_children_warehouses')) $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); + $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); $sql = 'SELECT ps.fk_product, ps.fk_entrepot FROM '.MAIN_DB_PREFIX.'product_stock ps @@ -103,27 +102,27 @@ function _action() ORDER BY p.ref ASC,p.label ASC'; - $Tab = $PDOdb->ExecuteAsArray($sql); - - foreach($Tab as &$row) { - - $inventory->add_product($PDOdb, $row->fk_product, $row->fk_entrepot); + $res = $db->query($sql); + if($res) { + while($obj = $db->fetch_object($res)){ + + $inventory->add_product($obj->fk_product, $obj->fk_entrepot); + } } - $inventory->save($PDOdb); + $inventory->update($user); + + header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=edit', 1)); + break; - header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->getId().'&action=edit', 1)); - case 'edit': if (!$user->rights->inventory->write) accessforbidden(); - $id = __get('id', 0, 'int'); - $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch(GETPOST('id')); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, __get('action', 'edit', 'string')); + _card($inventory, GETPOST('action')); break; @@ -389,29 +388,29 @@ function _list() llxFooter(''); } -function _fiche_warehouse(&$PDOdb, &$user, &$db, &$conf, $langs, $inventory) +function _card_warehouse(&$inventory) { + global $langs,$conf,$db, $user, $form; + dol_include_once('/categories/class/categorie.class.php'); llxHeader('',$langs->trans('inventorySelectWarehouse'),'',''); print dol_get_fiche_head(inventoryPrepareHead($inventory)); - $form=new TFormCore('inventory.php', 'confirmCreate'); - print $form->hidden('action', 'confirmCreate'); - $form->Set_typeaff('edit'); + echo '
    '; + echo ''; $formproduct = new FormProduct($db); - $formDoli = new Form($db); ?> - + - + @@ -421,11 +420,11 @@ function _fiche_warehouse(&$PDOdb, &$user, &$db, &$conf, $langs, $inventory) - + - + @@ -439,7 +438,8 @@ function _fiche_warehouse(&$PDOdb, &$user, &$db, &$conf, $langs, $inventory) print ''; print ''; - print $form->end_form(); + echo ''; + llxFooter(''); } @@ -455,7 +455,7 @@ function _card(&$inventory, $mode='edit') print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), '&action='.$mode)); $lines = array(); - _card_line($inventory, $lines, $form); + _card_line($inventory, $lines, $mode); print ''.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'

    '; @@ -488,7 +488,7 @@ function _card(&$inventory, $mode='edit') } -function _card_line(&$inventory, &$lines, &$form) +function _card_line(&$inventory, &$lines, $mode) { global $db; $inventory->amount_actual = 0; @@ -512,21 +512,23 @@ function _card_line(&$inventory, &$lines, &$form) if(!empty($TCacheEntrepot[$Inventorydet->fk_warehouse])) $e = $TCacheEntrepot[$Inventorydet->fk_warehouse]; elseif($e->fetch($Inventorydet->fk_warehouse) > 0) $TCacheEntrepot[$e->id] = $e; + $qty = (float)GETPOST('qty_to_add')[$k]; + $lines[]=array( 'produit' => $product->getNomUrl(1).' - '.$product->label ,'entrepot'=>$e->getNomUrl(1) ,'barcode' => $product->barcode - /*,'qty' => $form->texte('', 'qty_to_add['.$k.']', (isset($_REQUEST['qty_to_add'][$k]) ? $_REQUEST['qty_to_add'][$k] : 0), 8, 0, "style='text-align:center;'") - .($form->type_aff!='view' ? ''.img_picto('Ajouter', 'plus16@inventory').'' : '') + ,'qty' =>($mode == 'edit' ? '' : $qty ) + .($mode =='edit' ? ''.img_picto($langs->trans('Add'), 'plus16@inventory').'' : '') ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 ,'qty_stock' => $stock ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 - ,'action' => $user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '' + ,'action' => ($user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') ,'pmp_stock'=>round($pmp_actual,2) ,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) - ,'pmp_new'=>(!empty($user->rights->inventory->changePMP) ? $form->texte('', 'new_pmp['.$k.']',$Inventorydet->new_pmp, 8, 0, "style='text-align:right;'") - .($form->type_aff!='view' ? ''.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : '') : '' ) - */,'pa_stock'=>round($last_pa * $stock,2) + ,'pmp_new'=>(!empty($user->rights->inventory->changePMP) ? '' + .($mode =='edit' ? ''.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : '') : '') + ,'pa_stock'=>round($last_pa * $stock,2) ,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) ,'current_pa_stock'=>round($current_pa * $stock,2) ,'current_pa_actual'=>round($current_pa * $Inventorydet->qty_view,2) @@ -610,80 +612,9 @@ function exportCSV(&$inventory) { exit; } -function generateODT(&$PDOdb, &$db, &$conf, &$langs, &$inventory) -{ - $TBS=new TTemplateTBS(); - - $InventoryPrint = array(); // Tableau envoyé à la fonction render contenant les informations concernant l'inventaire - - foreach($inventory->Inventorydet as $k => $v) - { - $prod = new Product($db); - $prod->fetch($v->fk_product); - //$prod->fetch_optionals($prod->id); - - $InventoryPrint[] = array( - 'product' => $prod->ref.' - '.$prod->label - , 'qty_view' => $v->qty_view - ); - } - - $warehouse = new Entrepot($db); - $warehouse->fetch($inventory->fk_warehouse); - - $dirName = 'INVENTORY'.$inventory->getId().'('.date("d_m_Y").')'; - $dir = DOL_DATA_ROOT.'/inventory/'.$dirName.'/'; - - @mkdir($dir, 0777, true); - - $template = "templateINVENTORY.odt"; - //$template = "templateOF.doc"; - - $file_gen = $TBS->render(dol_buildpath('inventory/exempleTemplate/'.$template) - ,array( - 'InventoryPrint'=>$InventoryPrint - ) - ,array( - 'date_cre'=>$inventory->get_date('date_cre', 'd/m/Y') - ,'date_maj'=>$inventory->get_date('date_maj', 'd/m/Y H:i') - ,'date_inv'=>$inventory->get_date('date_inventory', 'd/m/Y') - ,'numero'=>empty($inventory->title) ? 'Inventaire n°'.$inventory->getId() : $inventory->title - ,'warehouse'=>$warehouse->libelle - ,'status'=>($inventory->status ? $langs->transnoentitiesnoconv('inventoryValidate') : $langs->transnoentitiesnoconv('inventoryDraft')) - ,'logo'=>DOL_DATA_ROOT."/mycompany/logos/".MAIN_INFO_SOCIETE_LOGO - ) - ,array() - ,array( - 'outFile'=>$dir.$inventory->getId().".odt" - ,"convertToPDF"=>(!empty($conf->global->INVENTORY_GEN_PDF) ? true : false) - ,'charset'=>OPENTBS_ALREADY_UTF8 - - ) - - ); - - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=inventory&entity=".$conf->entity."&file=".$dirName."/".$inventory->getId(). (!empty($conf->global->INVENTORY_GEN_PDF) ? '.pdf' : '.odt') ); - - /* - $size = filesize("./" . basename($file_gen)); - header("Content-Type: application/force-download; name=\"" . basename($file_gen) . "\""); - header("Content-Transfer-Encoding: binary"); - header("Content-Length: $size"); - header("Content-Disposition: attachment; filename=\"" . basename($file_gen) . "\""); - header("Expires: 0"); - header("Cache-Control: no-cache, must-revalidate"); - header("Pragma: no-cache"); - - readfile($file_gen); - */ - - //header("Location: ".DOL_URL_ROOT."/document.php?modulepart=asset&entity=1&file=".$dirName."/".$assetOf->numero.".doc"); - -} function _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actual, $total_current_pa,$total_current_pa_actual) { global $conf,$user,$langs; - if ($view['can_validate'] == 1) { ?> diff --git a/htdocs/inventory/tpl/inventory.tpl.php b/htdocs/inventory/tpl/inventory.tpl.php index d7022245f5b..8a3bfd0f2a6 100644 --- a/htdocs/inventory/tpl/inventory.tpl.php +++ b/htdocs/inventory/tpl/inventory.tpl.php @@ -154,9 +154,9 @@ - - - @@ -168,18 +168,17 @@
    - trans('Print') ?> trans('ExportCSV') ?> trans('Modify') ?> rights->inventory->changePMP)) { - echo ''.$langs->trans('ApplyPMP').''; } if ($can_validate == 1) { ?> - Réguler le stock + Réguler le stock @@ -196,7 +195,6 @@
    - trans('Print') ?> trans('ExportCSV') ?> trans('Delete') ?> From a463759ba3b88cdcc97a263c2cd6e42d5944aaf7 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Wed, 14 Dec 2016 16:54:05 +0100 Subject: [PATCH 008/172] init query builder into db --- htdocs/core/class/coreobject.class.php | 98 +++++++++++++++++++++- htdocs/core/db/DoliDB.class.php | 108 +++++++++++++++++++++++++ 2 files changed, 203 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index f5e5b0e79a1..8f55a5bf458 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -150,7 +150,7 @@ class CoreObject extends CommonObject { foreach ($this->__fields as $field=>$info) { - if($this->_is_date($info)){ + if($this->is_date($info)){ if(empty($this->{$field})){ $query[$field] = $this->date_0; } @@ -166,11 +166,11 @@ class CoreObject extends CommonObject { $query[$field] = (int)price2num($this->{$field}); } - else if($this->_is_float($info)){ + else if($this->is_float($info)){ $query[$field] = (double)price2num($this->{$field}); } - elseif($this->_is_null($info)) { + elseif($this->is_null($info)) { $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0')?null:$this->{$field}); } else{ @@ -264,6 +264,20 @@ class CoreObject extends CommonObject { return $k; } + + public function removeChild($tabName, $id, $key='id') { + foreach($this->{$tabName} as &$object) { + + if($object->{$key} == $id) { + $object->to_delete = true; + return true; + } + + + } + return false; + } + public function fetchChild() { if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { @@ -295,18 +309,96 @@ class CoreObject extends CommonObject { } + public function saveChild(User &$user) { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { + foreach($this->childtables as &$childTable) { + + $className = ucfirst($childTable); + + foreach($this->{$className} as $i => &$object) { + + $object->{$this->fk_element} = $this->id; + + $object->update($user); + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); + } + + } + } + } public function update(User &$user) { if(empty($this->id )) return $this->create($user); + if(isset($this->to_delete) && $this->to_delete==true) { + $this->delete(); + } + else { + + $query = array(); + + $query['id']=$this->id; + if(!isset($this->no_dt_maj))$query['tms'] = date('Y-m-d H:i:s'); + $this->set_save_query($query); + + $this->db->update($this->table_element,$query,array('id')); + + $this->id = $this->db->last_insert_id($this->table_element); + + $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); + + $this->saveChild($user); + + } + return $this->id; + } public function create(User &$user) { if($this->id>0) return $this->update($user); + $query = array(); + $query['datec'] = date("Y-m-d H:i:s",$this->datec); + if(!isset($this->no_dt_maj))$query['tms'] = date('Y-m-d H:i:s'); + $this->set_save_query($query); + + $this->db->insert($this->table_element,$query); + + $this->id = $this->db->last_insert_id($this->table_element); + + $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); + + $this->saveChild($user); + + + return $this->id; } + public function delete(){ + if($this->id>0){ + $this->call_trigger(strtoupper($this->element). '_DELETE', $user); + $this->db->delete($this->table_element,array('id'=>$this->id),array(0=>'id')); + + if($this->withChild) { + foreach($this->childtables as &$childTable) { + + $className = ucfirst($childTable); + foreach($this->{$className} as &$object) { + + $object->delete(); + + } + + } + } + + + + } + + + } public function get_date($field,$format='') { if(empty($this->{$field})) return ''; elseif($this->{$field}<=strtotime('1000-01-01 00:00:00')) return ''; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c63227e1601..395f6009169 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -288,5 +288,113 @@ abstract class DoliDB implements Database { return $this->lastqueryerror; } + + /** + * Generate and execute Update SQL commande + * + * @param string $table table to update + * @param array $values array of values to update + * @param int|string|array $key key of value to select row to update + * @return bool|result false or boolean + */ + function update($table,$values,$key){ + + foreach ($value as $k => $v) { + if(is_string($v)) $v=stripslashes($v); + + if (is_array($key)){ + $i=array_search($k , $key ); + if ( $i !== false) { + $where[] = $key[$i]."=" . $this->escape( $v ) ; + continue; + } + } else { + if ( $k == $key) { + $where[] = "$k=" .$this->escape( $v ) ; + continue; + } + } + + if(is_null($v)) $val = 'NULL'; + else if(is_int($v) || is_double($v)) $val=$v; + else $val = $this->escape( $v ); + + $tmp[] = "$k=$val"; + } + $sql = sprintf( "UPDATE $table SET %s WHERE %s" , implode( ",", $tmp ) , implode(" AND ",$where) ); + + $res = $this->query( $sql ); + + if($res===false) { + //error + return false; + } + + return true; + } + + /** + * Generate and execute Insert SQL commande + * + * @param string $table table to update + * @param array $values array of values to update + * @return bool|result false or boolean + */ + function insert($table,$values){ + + foreach ($values as $k => $v) { + + $fields[] = $k; + if(is_null($v)){ + $values[] = 'NULL'; + }else{ + $v=stripslashes($v); + $values[] =$this->escape( $v ); + } + } + $sql = sprintf( 'INSERT INTO '.$table.' ( %s ) values( %s ) ', implode( ",", $fields ) , implode( ",", $values ) ); + + $res = $this->query($sql); + + if($res===false) { + + return false; + } + + return true; + } + + /** + * Generate and execute Delete SQL commande + * + * @param string $table table for the delete + * @param array $values array of values to delete + * @param int|string|array $key key of value to select row to update + * @return bool|result false or boolean + */ + function delete($table,$values,$key){ + foreach ($values as $k => $v) { + if(is_string($v)) $v=stripslashes($v); + + if (is_array($key)){ + $i=array_search($k , $key ); + if ( $i !== false) { + $where[] = $key[$i]."=" . $this->escape( $v ) ; + continue; + } + } else { + if ( $k == $key) { + $where[] = "$k=" .$this->escape( $v ) ; + continue; + } + } + + } + + $sql = sprintf( 'DELETE FROM '.$table.' WHERE '.implode(" AND ",$where)); + + return $this->query( $sql ); + } + } From 703b8708e3702b21cf4027e2ad0d5c071298dfab Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 10:39:59 +0100 Subject: [PATCH 009/172] fix create --- htdocs/core/class/coreobject.class.php | 66 +++-- htdocs/core/db/DoliDB.class.php | 55 ++-- htdocs/core/modules/modinventory.class.php | 329 +++++++++++++++++++++ htdocs/inventory/class/inventory.class.php | 4 +- htdocs/inventory/img/bt-save.png | Bin 0 -> 493 bytes htdocs/inventory/inventory.php | 5 +- 6 files changed, 401 insertions(+), 58 deletions(-) create mode 100644 htdocs/core/modules/modinventory.class.php create mode 100644 htdocs/inventory/img/bt-save.png diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 8f55a5bf458..7613a556092 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -31,7 +31,14 @@ class CoreObject extends CommonObject { public $withChild = true; - protected $__fields=array(); + public $no_update_tms = false; + + public $date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? + + /* + * @var Array $_fields Fields to synchronize with Database + */ + protected $__fields=array(); /** * Constructor * @@ -39,7 +46,7 @@ class CoreObject extends CommonObject { */ function __construct(DoliDB &$db) { - $this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? + } protected function init() { @@ -142,11 +149,7 @@ class CoreObject extends CommonObject { private function set_save_query(){ - $query=array( - 'rowid'=>$this->id - ,'datec'=>($this->id>0 ? $this->db->jdate($this->datec) : time()) - ,'tms'=>time() - ); + $query=array(); foreach ($this->__fields as $field=>$info) { @@ -315,20 +318,21 @@ class CoreObject extends CommonObject { foreach($this->childtables as &$childTable) { $className = ucfirst($childTable); - - foreach($this->{$className} as $i => &$object) { - - $object->{$this->fk_element} = $this->id; - - $object->update($user); - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); + if(!empty($this->{$className})) { + foreach($this->{$className} as $i => &$object) { + + $object->{$this->fk_element} = $this->id; + + $object->update($user); + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); + } } } } } public function update(User &$user) { - if(empty($this->id )) return $this->create($user); + if(empty($this->id )) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed if(isset($this->to_delete) && $this->to_delete==true) { $this->delete(); @@ -337,10 +341,10 @@ class CoreObject extends CommonObject { $query = array(); + $query = $this->set_save_query(); $query['id']=$this->id; - if(!isset($this->no_dt_maj))$query['tms'] = date('Y-m-d H:i:s'); - $this->set_save_query($query); - + if(empty($this->no_update_tms))$query['tms'] = date('Y-m-d H:i:s'); + $this->db->update($this->table_element,$query,array('id')); $this->id = $this->db->last_insert_id($this->table_element); @@ -358,21 +362,25 @@ class CoreObject extends CommonObject { if($this->id>0) return $this->update($user); $query = array(); + $query = $this->set_save_query(); $query['datec'] = date("Y-m-d H:i:s",$this->datec); - if(!isset($this->no_dt_maj))$query['tms'] = date('Y-m-d H:i:s'); - $this->set_save_query($query); - - $this->db->insert($this->table_element,$query); - - $this->id = $this->db->last_insert_id($this->table_element); + if(empty($this->no_update_tms))$query['tms'] = date('Y-m-d H:i:s'); - $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); - - $this->saveChild($user); + $res = $this->db->insert($this->table_element,$query); + if($res) { + $this->id = $this->db->last_insert_id($this->table_element); + + $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); + + $this->saveChild($user); + + return $this->id; + } + else{ + return false; + } - return $this->id; - } public function delete(){ if($this->id>0){ diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 395f6009169..85766c31949 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -288,6 +288,19 @@ abstract class DoliDB implements Database { return $this->lastqueryerror; } + /* + * Add quote to field value if necessary + * + * @param string|int $value value to protect + * @return string|int + */ + function quote($value) { + + if(is_null($value)) return 'NULL'; + else if(is_numeric($value)) return $value; + else return "'".$this->escape( $value )."'"; + + } /** * Generate and execute Update SQL commande @@ -297,31 +310,27 @@ abstract class DoliDB implements Database * @param int|string|array $key key of value to select row to update * @return bool|result false or boolean */ - function update($table,$values,$key){ + function update($table,$fields,$key){ - foreach ($value as $k => $v) { + foreach ($fields as $k => $v) { if(is_string($v)) $v=stripslashes($v); if (is_array($key)){ $i=array_search($k , $key ); if ( $i !== false) { - $where[] = $key[$i]."=" . $this->escape( $v ) ; + $where[] = $key[$i].'=' . $this->quote( $v ) ; continue; } } else { if ( $k == $key) { - $where[] = "$k=" .$this->escape( $v ) ; + $where[] = $k.'=' .$this->quote( $v ) ; continue; } } - if(is_null($v)) $val = 'NULL'; - else if(is_int($v) || is_double($v)) $val=$v; - else $val = $this->escape( $v ); - - $tmp[] = "$k=$val"; + $tmp[] = $k.'='.$this->quote($val); } - $sql = sprintf( "UPDATE $table SET %s WHERE %s" , implode( ",", $tmp ) , implode(" AND ",$where) ); + $sql = sprintf( 'UPDATE '.MAIN_DB_PREFIX.$table.' SET %s WHERE %s' , implode( ',', $tmp ) , implode(' AND ',$where) ); $res = $this->query( $sql ); @@ -340,22 +349,18 @@ abstract class DoliDB implements Database * @param array $values array of values to update * @return bool|result false or boolean */ - function insert($table,$values){ + function insert($table,$fields){ - foreach ($values as $k => $v) { + foreach ($fields as $k => $v) { - $fields[] = $k; - if(is_null($v)){ - $values[] = 'NULL'; - }else{ - $v=stripslashes($v); - $values[] =$this->escape( $v ); - } + $keys[] = $k; + $values[] = $this->quote($v); + } - $sql = sprintf( 'INSERT INTO '.$table.' ( %s ) values( %s ) ', implode( ",", $fields ) , implode( ",", $values ) ); - - $res = $this->query($sql); + $sql = sprintf( 'INSERT INTO '.MAIN_DB_PREFIX.$table.' ( %s ) values( %s ) ', implode( ",", $keys ) , implode( ",", $values ) ); + + $res = $this->query($sql); if($res===false) { return false; @@ -372,8 +377,8 @@ abstract class DoliDB implements Database * @param int|string|array $key key of value to select row to update * @return bool|result false or boolean */ - function delete($table,$values,$key){ - foreach ($values as $k => $v) { + function delete($table,$fields,$key){ + foreach ($fields as $k => $v) { if(is_string($v)) $v=stripslashes($v); if (is_array($key)){ @@ -391,7 +396,7 @@ abstract class DoliDB implements Database } - $sql = sprintf( 'DELETE FROM '.$table.' WHERE '.implode(" AND ",$where)); + $sql = sprintf( 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.implode(' AND ',$where)); return $this->query( $sql ); } diff --git a/htdocs/core/modules/modinventory.class.php b/htdocs/core/modules/modinventory.class.php new file mode 100644 index 00000000000..10fb1cc477e --- /dev/null +++ b/htdocs/core/modules/modinventory.class.php @@ -0,0 +1,329 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * 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 + * 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 . + */ + +/** + * \defgroup inventory Module inventory + * \brief Example of a module descriptor. + * Such a file must be copied into htdocs/inventory/core/modules directory. + * \file htdocs/inventory/core/modules/modinventory.class.php + * \ingroup inventory + * \brief Description and activation file for module inventory + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Description and activation class for module inventory + */ +class modinventory extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $langs,$conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 104420; // 104000 to 104999 for ATM CONSULTING + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'inventory'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "products"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Description of module inventory"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 0; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='inventory@inventory'; + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /inventory/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /inventory/core/modules/barcode) + // for specific css file (eg: /inventory/css/inventory.css.php) + //$this->module_parts = array( + // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) + // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) + // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) + // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) + // 'css' => array('/inventory/css/inventory.css.php'), // Set this to relative path of css file if module has its own css file + // 'js' => array('/inventory/js/inventory.js'), // Set this to relative path of js file if module must load a js on all pages + // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module + // 'dir' => array('output' => 'othermodulename'), // To force the default directories names + // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@inventory')) // Set here all workflow context managed by module + // ); + $this->module_parts = array(); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/inventory/temp"); + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into inventory/admin directory, to use to setup module. + $this->config_page_url = array("inventory_setup.php@inventory"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array('modStock'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->phpmin = array(5,0); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module + $this->langfiles = array("inventory@inventory"); + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array(); + + // Array to add new pages in new tabs + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@inventory:$user->rights->inventory->read:/inventory/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:mylangfile@inventory:$user->rights->othermodule->read:/inventory/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + $this->tabs = array(); + + // Dictionaries + if (! isset($conf->inventory->enabled)) + { + $conf->inventory=new stdClass(); + $conf->inventory->enabled=0; + } + $this->dictionaries=array(); + /* Example: + if (! isset($conf->inventory->enabled)) $conf->inventory->enabled=0; // This is to avoid warnings + $this->dictionaries=array( + 'langs'=>'mylangfile@inventory', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Table1","Table2","Table3"), // Label of tables + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order + 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->inventory->enabled,$conf->inventory->enabled,$conf->inventory->enabled) // Condition to show each dictionary + ); + */ + + // Boxes + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + $this->boxes = array(); // List of boxes + // Example: + //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); + + $langs->load('inventory@inventory'); + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + // Add here list of permission defined by an id, a label, a boolean and two constant strings. + // Example: + // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + // $this->rights[$r][1] = 'Permision label'; // Permission label + // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $r++; + + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'inventoryReadPermission'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'inventoryWritePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + // + // Example to declare a new Top Menu entry and its Left menu entry: + // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'inventory top menu', + // 'mainmenu'=>'inventory', + // 'leftmenu'=>'inventory', + // 'url'=>'/inventory/pagetop.php', + // 'langs'=>'mylangfile@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. + // 'perms'=>'1', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry into an existing Top menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'inventory left menu', + // 'mainmenu'=>'xxx', + // 'leftmenu'=>'inventory', + // 'url'=>'/inventory/pagelevel2.php', + // 'langs'=>'mylangfile@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + // 'perms'=>'1', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry + 'titre'=>'Liste des inventaires', + 'mainmenu'=>'inventory', + 'leftmenu'=>'inventory', + 'url'=>'/inventory/inventory.php?action=list', + 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry + 'titre'=>'Nouvel inventaire', + 'mainmenu'=>'inventory', + 'leftmenu'=>'inventory', + 'url'=>'/inventory/inventory.php?action=create', + 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; + + // Exports + $r=1; + + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); + // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $this->export_sql_order[$r] .=' ORDER BY s.nom'; + // $r++; + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + $sql = array(); + define('INC_FROM_DOLIBARR', true); + dol_include_once('/inventory/config.php'); + dol_include_once("/inventory/script/create-maj-base.php"); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options='') + { + $sql = array(); + + return $this->_remove($sql, $options); + } + +} diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index f2ff6484c64..76ed46c4aa8 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -159,7 +159,7 @@ class Inventory extends CoreObject parent::update($user); } - function set_values($Tab) + function set_values(&$Tab) { global $db,$langs; @@ -183,7 +183,7 @@ class Inventory extends CoreObject } } - return parent::set_values($Tab); + parent::set_values($Tab); } function deleteAllLine() { diff --git a/htdocs/inventory/img/bt-save.png b/htdocs/inventory/img/bt-save.png new file mode 100644 index 0000000000000000000000000000000000000000..f20d292ca91805ab875cbb48391cba2e94e3f194 GIT binary patch literal 493 zcmV;DB6!8NR z1gjKw5($c?FkoS2VIkVsX<-$VG!`O)SSTs9h<{)au@C}cZ*M*ziUuSX&F#!aXZG$i zF&9m6;4!yzJ8$32ENkWSdHAnIZeIpIwANtTHV_dIA}9tb14(>v14}z6zFdUW+_4$A*W93~2-T2sq_LIMs7|t<;^mkZ8tnBIC^H<%a2WSO j#)$U$lt^ynQ-A>gD&Upv=pk<>00000NkvXXu0mjflc~?j literal 0 HcmV?d00001 diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index 4e70ee1b4cc..1d9ec174257 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -77,6 +77,7 @@ function _action() $inventory->set_values($_POST); $fk_inventory = $inventory->create($user); + $fk_category = (int)GETPOST('fk_category'); $fk_supplier = (int)GETPOST('fk_supplier'); $fk_warehouse = (int)GETPOST('fk_warehouse'); @@ -490,7 +491,7 @@ function _card(&$inventory, $mode='edit') function _card_line(&$inventory, &$lines, $mode) { - global $db; + global $db,$langs,$user,$conf; $inventory->amount_actual = 0; $TCacheEntrepot = array(); @@ -523,7 +524,7 @@ function _card_line(&$inventory, &$lines, $mode) ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 ,'qty_stock' => $stock ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 - ,'action' => ($user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') + ,'action' => ($user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') ,'pmp_stock'=>round($pmp_actual,2) ,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) ,'pmp_new'=>(!empty($user->rights->inventory->changePMP) ? '' From 81b01cd05529218ac7dda3a7ad7c55b1fca6d268 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 11:23:13 +0100 Subject: [PATCH 010/172] fix --- htdocs/core/class/coreobject.class.php | 21 +-- htdocs/core/db/DoliDB.class.php | 26 ++-- htdocs/inventory/admin/inventory_setup.php | 168 +++++++++++++++++++++ htdocs/inventory/ajax/ajax.inventory.php | 19 +-- htdocs/inventory/img/plus.png | Bin 0 -> 1299 bytes htdocs/inventory/img/plus16.png | Bin 0 -> 665 bytes htdocs/inventory/inventory.php | 68 ++++----- htdocs/inventory/tpl/inventory.tpl.php | 6 +- 8 files changed, 239 insertions(+), 69 deletions(-) create mode 100644 htdocs/inventory/admin/inventory_setup.php create mode 100644 htdocs/inventory/img/plus.png create mode 100644 htdocs/inventory/img/plus16.png diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 7613a556092..75706403069 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -342,10 +342,10 @@ class CoreObject extends CommonObject { $query = array(); $query = $this->set_save_query(); - $query['id']=$this->id; + $query['rowid']=$this->id; if(empty($this->no_update_tms))$query['tms'] = date('Y-m-d H:i:s'); - $this->db->update($this->table_element,$query,array('id')); + $this->db->update($this->table_element,$query,array('rowid')); $this->id = $this->db->last_insert_id($this->table_element); @@ -382,19 +382,22 @@ class CoreObject extends CommonObject { } } - public function delete(){ + public function delete(User &$user){ if($this->id>0){ $this->call_trigger(strtoupper($this->element). '_DELETE', $user); - $this->db->delete($this->table_element,array('id'=>$this->id),array(0=>'id')); - if($this->withChild) { + $this->db->delete($this->table_element,array('rowid'=>$this->id),array('rowid')); + + if($this->withChild && !empty($this->childtables)) { foreach($this->childtables as &$childTable) { $className = ucfirst($childTable); - foreach($this->{$className} as &$object) { - - $object->delete(); - + if(!empty($this->{$className})) { + foreach($this->{$className} as &$object) { + + $object->delete($user); + + } } } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 85766c31949..da0717e665b 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -313,7 +313,6 @@ abstract class DoliDB implements Database function update($table,$fields,$key){ foreach ($fields as $k => $v) { - if(is_string($v)) $v=stripslashes($v); if (is_array($key)){ $i=array_search($k , $key ); @@ -328,10 +327,9 @@ abstract class DoliDB implements Database } } - $tmp[] = $k.'='.$this->quote($val); + $tmp[] = $k.'='.$this->quote($v); } - $sql = sprintf( 'UPDATE '.MAIN_DB_PREFIX.$table.' SET %s WHERE %s' , implode( ',', $tmp ) , implode(' AND ',$where) ); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ; $res = $this->query( $sql ); if($res===false) { @@ -358,7 +356,9 @@ abstract class DoliDB implements Database } - $sql = sprintf( 'INSERT INTO '.MAIN_DB_PREFIX.$table.' ( %s ) values( %s ) ', implode( ",", $keys ) , implode( ",", $values ) ); + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.' + ( '.implode( ",", $keys ).' ) + VALUES ( '.implode( ",", $values ).' ) '; $res = $this->query($sql); if($res===false) { @@ -379,26 +379,30 @@ abstract class DoliDB implements Database */ function delete($table,$fields,$key){ foreach ($fields as $k => $v) { - if(is_string($v)) $v=stripslashes($v); - if (is_array($key)){ $i=array_search($k , $key ); if ( $i !== false) { - $where[] = $key[$i]."=" . $this->escape( $v ) ; + $where[] = $key[$i].'=' . $this->quote( $v ) ; continue; } } else { if ( $k == $key) { - $where[] = "$k=" .$this->escape( $v ) ; + $where[] = $k.'='.$this->quote( $v ) ; continue; } } } - $sql = sprintf( 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.implode(' AND ',$where)); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.implode(' AND ',$where); - return $this->query( $sql ); + $res = $this->query( $sql ); + if($res===false) { + return false; + } + + return true; + } } diff --git a/htdocs/inventory/admin/inventory_setup.php b/htdocs/inventory/admin/inventory_setup.php new file mode 100644 index 00000000000..f55bc092517 --- /dev/null +++ b/htdocs/inventory/admin/inventory_setup.php @@ -0,0 +1,168 @@ + + * Copyright (C) 2015 ATM Consulting + * + * 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 admin/inventory.php + * \ingroup inventory + * \brief This file is an example module setup page + * Put some comments here + */ +// Dolibarr environment +$res = @include("../../main.inc.php"); // From htdocs directory +if (! $res) { + $res = @include("../../../main.inc.php"); // From "custom" directory +} + +// Libraries +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once '../lib/inventory.lib.php'; + +// Translations +$langs->load("inventory@inventory"); + +// Access control +if (! $user->admin) { + accessforbidden(); +} + +// Parameters +$action = GETPOST('action', 'alpha'); + +/* + * Actions + */ +if (preg_match('/set_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_del_const($db, $code, 0) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +/* + * View + */ +$page_name = "inventorySetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = '' + . $langs->trans("BackToModuleList") . ''; +print_fiche_titre($langs->trans($page_name), $linkback); + +// Configuration header +$head = inventoryAdminPrepareHead(); +dol_fiche_head( + $head, + 'settings', + $langs->trans("Module104420Name"), + 0, + "inventory@inventory" +); + +// Setup page goes here +$form=new Form($db); +$var=false; +print '
    trans('Title') ?>texte('', 'title', '',50,255) ?>
    trans('Date') ?>calendrier('', 'date_inventory',time()) ?>select_date(time(),'date_inventory'); ?>
    trans('SelectCategory') ?>select_all_categories(0,'', 'fk_category') ?>select_all_categories(0,'', 'fk_category') ?>
    trans('SelectFournisseur') ?>select_thirdparty('','fk_supplier','s.fournisseur = 1') ?>select_thirdparty('','fk_supplier','s.fournisseur = 1') ?>
    trans('OnlyProdsInStock') ?>
     
    '; +print ''; +print ''."\n"; +print ''; +print ''."\n"; + + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +print '
    '.$langs->trans("Parameters").' '.$langs->trans("Value").'
    '.$langs->trans("INVENTORY_GEN_PDF").' '; +print '
    '; +print ''; +print ''; +print $form->selectyesno("INVENTORY_GEN_PDF",$conf->global->INVENTORY_GEN_PDF,1); +print ''; +print '
    '; +print '
    '.$langs->trans("INVENTORY_DISABLE_VIRTUAL").' '; +print '
    '; +print ''; +print ''; +print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1); +print ''; +print '
    '; +print '
    '.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; +print '
    '; +print ''; +print ''; +print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1); +print ''; +print '
    '; +print '
    '.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; +print '
    '; +print ''; +print ''; +print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1); +print ''; +print '
    '; +print '
    '; + +llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/inventory/ajax/ajax.inventory.php b/htdocs/inventory/ajax/ajax.inventory.php index 34efecfab8f..f2f5ef54903 100644 --- a/htdocs/inventory/ajax/ajax.inventory.php +++ b/htdocs/inventory/ajax/ajax.inventory.php @@ -1,24 +1,21 @@ rights->inventory->write) { echo -1; exit; } $fk_det_inventory = GETPOST('fk_det_inventory'); - $det = new Inventorydet; - if( $det->load($PDOdb, $fk_det_inventory)) { + $det = new Inventorydet($db); + if( $det->fetch( $fk_det_inventory)) { $det->qty_view+=GETPOST('qty'); - $det->save($PDOdb); + $det->update($user); echo $det->qty_view; } @@ -33,10 +30,10 @@ $fk_det_inventory = GETPOST('fk_det_inventory'); - $det = new Inventorydet; - if( $det->load($PDOdb, $fk_det_inventory)) { + $det = new Inventorydet($db); + if( $det->fetch( $fk_det_inventory)) { $det->new_pmp=price2num(GETPOST('pmp')); - $det->save($PDOdb); + $det->update($user); echo $det->new_pmp; } diff --git a/htdocs/inventory/img/plus.png b/htdocs/inventory/img/plus.png new file mode 100644 index 0000000000000000000000000000000000000000..b7072a96960e30374c5d4f6a5e9bfc374e7a532a GIT binary patch literal 1299 zcmV+u1?>8XP)?02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00etUL_t(o!?l;qYaC@9$3Hun z-R>r7NwP^cY02AGDU_xVmNpiZDhL+DlP!XX2QLa1CD6aXqaGA`Q1IZ{Lr;QO>Ol{R zp2WMMHcbebDalT=vzd8bJ!ED(nQqc;n|$G6W}auB-}m?a%oI2Pqobn$Jb3URohsGq z^^t0|Is^<^Yb(YWwAO7YWe^0x*4o~|lP4?HYW4b=GiSc2)oMt& zOQw`UDb=}`Qlhm+2+>&!g24E`zZ3+)w{aYcxw$!3R#wnjAFM#FR%2shgHxwYU0PgR zyg5ET-Y66b8FGzMa*qP}d!-b{7=#eCTCG3V*VjLeqUfI|dSHBf9MAJOckbMk3l}cj zs#GfddkHjJ?>-A5&|2>y*IIYHk&fiu*!TUnTdmd|$8j*mbU6F63WQGFf=qov)N=~VxqFRxcK|%=;%V$eR($vA@F_w zmJp(4j3FsQ3k>#G`mbuUyEk1k#&nd>S`$Ul-_2(8)wDv~YPFgwaASCQcp+;^-a08I zJ3BiBL9lf1-o5)-@0CiWsp;wItLd|~mMDq{!;mP7I!ak<7l03dZvfn+QH;#a&VFu; z=^DqpLXP9O`D}Jw*G*l$y}eDd*?g?zGWZ(!4p1&YqtRFz7#Q4B$Jr3%vpk!{DU?!p zp2yD4PS^DuO288Er2~}5#>U=AJ6bl=(~+G^70E*gK^TU;kf(Sbz&(5RY_+eiZ?2p5 zLI|QLVz=e)mQ)ftIJk1TgKEN~K|?)EMwsBiY*8`oZ(OPm9H3(OQeO79oU< zqR8taa21%!DPn-HfOor{FTjLrtsODOIN9V&6%ay%zVCZITBH&s@@Vh#{xM+Kl~SI_ zHjJzS#+U-nkNspgK*deFS{j0UH#=&$g+d`vN_9#pOKyy@hrqF)3mTQhJW#Od4%Sd%2Vn&-1PU*Sc)3 z19x+CQ^3DZ;hAk<-C12--IPM!)mo!6r{3Dy8dA!m4F5W?>KJ38`Lm>YJc;Q)VwFGe zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00IF?L_t(I%YBf)Yg17i#Xm23 zFPK1Dy0mf1E9sDe1d2mr5Hg8_7!f0Mh@0T9ga1V9(A9sSgE-YX3I4#X2pz;BSuD}m z)YeCH-@WhNyq7wd7oH*QfdgOoo^$wqk3|9-8yoEG>`<%K8ihik7KYKH)&WYXqh7D~ zx!rE>uB@!k>2xL@D;co9zFsYrN_%s2a|^!jqm-IZYmMi5zmJcPZ}>b5A}Ne zQKeFO17v;QM@os5^1qNMigLDXKd~(9n^Nj4K)Tgxk$J`r&9adTWgNVF5IoO)rzl%xkR)f*?Nk#s2>OGXU3hw=Bzg zdU|?_5P~R*0FHoyU9DE{JB~B&`#xH0;*cN+ocO(Nx9fyq$P|`4-O8V$HrVPhm;cF^_T#SL_on- zN}Z=tsmbX{jLnzAR!aR!rBaxoK?t!3YylbI1Mq6BYXbH03rh+APu!w=uUsylyRLf< zB)OdsZcpuE-T|OkES@-yGrinQ1Z>VQcL7*lUdFcV>oWvr!1poFX6)Cd`*?7{nX`EJ zqEgp@-X+FE;9AmPT@Z8&xCvaHv<;ttchkbZ0%0!T4SB2a00000NkvXXu0mjfN$Dr+ literal 0 HcmV?d00001 diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index 1d9ec174257..ccda1b37c0e 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -131,7 +131,7 @@ function _action() if (!$user->rights->inventory->write) accessforbidden(); - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); $inventory->load($PDOdb, $id); @@ -153,7 +153,7 @@ function _action() case 'regulate': - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); $inventory->load($PDOdb, $id); @@ -174,10 +174,10 @@ function _action() case 'changePMP': - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch( $id ); $inventory->changePMP($PDOdb); @@ -188,12 +188,11 @@ function _action() case 'add_line': if (!$user->rights->inventory->write) accessforbidden(); - - $id = __get('id', 0, 'int'); - $fk_warehouse = __get('fk_warehouse', 0, 'int'); + $id = GETPOST('id'); + $fk_warehouse = GETPOST('fk_warehouse'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch( $id ); $type = (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) ? 'string' : 'int'); //AA heu ? @@ -245,16 +244,17 @@ function _action() //Cette action devrais se faire uniquement si le status de l'inventaire est à 0 mais aucune vérif - $rowid = __get('rowid', 0, 'int'); - $Inventorydet = new Inventory($db); - $Inventorydet->load($PDOdb, $rowid); - $Inventorydet->delete($PDOdb); - - $id = __get('id', 0, 'int'); + $rowid = GETPOST('rowid'); + $Inventorydet = new Inventorydet($db); + if($Inventorydet->fetch($rowid)>0) { + $Inventorydet->delete($user); + setEventMessage("ProductDeletedFromInventory"); + } + $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch( $id); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + _card($inventory, 'edit'); break; case 'flush': @@ -519,16 +519,14 @@ function _card_line(&$inventory, &$lines, $mode) 'produit' => $product->getNomUrl(1).' - '.$product->label ,'entrepot'=>$e->getNomUrl(1) ,'barcode' => $product->barcode - ,'qty' =>($mode == 'edit' ? '' : $qty ) - .($mode =='edit' ? ''.img_picto($langs->trans('Add'), 'plus16@inventory').'' : '') + ,'qty' =>($mode == 'edit' ? ' '.img_picto($langs->trans('Add'), 'plus16@inventory').'' : '' ) ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 ,'qty_stock' => $stock ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 ,'action' => ($user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') ,'pmp_stock'=>round($pmp_actual,2) ,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) - ,'pmp_new'=>(!empty($user->rights->inventory->changePMP) ? '' - .($mode =='edit' ? ''.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : '') : '') + ,'pmp_new'=>(!empty($user->rights->inventory->changePMP && $mode =='edit') ? ' '.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : price($Inventorydet->new_pmp)) ,'pa_stock'=>round($last_pa * $stock,2) ,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) ,'current_pa_stock'=>round($current_pa * $stock,2) @@ -656,24 +654,24 @@ function _headerList($view) { ?>   Produit - Entrepôt + trans('Warehouse'); ?> barcode->enabled)) { ?> - Code-barre + trans('Barcode'); ?> - Quantité théorique + trans('TheoricalQty'); ?> global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ - echo 'Valeur théorique'; + echo ''.$langs->trans('TheoricalValue').''; } else { - echo 'Valeur théorique'; + echo ''.$langs->trans('TheoricalValue').''; } ?> - Quantité réelle + trans('RealQty'); ?> global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) $colspan++; if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) $colspan++; - echo 'Valeur réelle'; + echo ''.$langs->trans('RealValue').''; ?> - Quantité régulée + trans('RegulatedQty'); ?> # - +   - PMP - Dernier PA + trans('PMP'); ?> + trans('LastPA'); ?> global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ - echo 'PA courant'; + echo ''.$langs->trans('CurrentPA').''; } ?>   - PMP + trans('PMP'); ?> rights->inventory->changePMP)) { echo ''.$langs->trans('ColumnNewPMP').''; } ?> - Dernier PA + trans('LastPA'); ?> global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ - echo 'PA courant'; + echo ''.$langs->trans('CurrentPA').''; } ?> diff --git a/htdocs/inventory/tpl/inventory.tpl.php b/htdocs/inventory/tpl/inventory.tpl.php index 8a3bfd0f2a6..c3c1347446b 100644 --- a/htdocs/inventory/tpl/inventory.tpl.php +++ b/htdocs/inventory/tpl/inventory.tpl.php @@ -8,7 +8,7 @@ $('#a_save_qty_'+k).hide(); $.ajax({ - url:"script/interface.php" + url:"ajax/ajax.inventory.php" ,data:{ 'fk_det_inventory' : fk_det_inventory ,'qty': qty @@ -37,7 +37,7 @@ $('#a_save_new_pmp_'+k).hide(); $.ajax({ - url:"script/interface.php" + url:"ajax/ajax.inventory.php" ,data:{ 'fk_det_inventory' : fk_det_inventory ,'pmp': pmp @@ -137,7 +137,7 @@ rights->inventory->changePMP)) { - echo ''.$row['pmp_new'].''; + echo ''.$row['pmp_new'].''; } ?> From 9f6f87465503e57e757b46b4de0c783a510f17b8 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 12:33:26 +0100 Subject: [PATCH 011/172] fix --- htdocs/core/class/coreobject.class.php | 4 +- htdocs/core/db/DoliDB.class.php | 2 +- htdocs/inventory/class/inventory.class.php | 55 ++++++++++++---- htdocs/inventory/inventory.php | 73 ++++++---------------- 4 files changed, 64 insertions(+), 70 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 75706403069..50b59761b1d 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -158,7 +158,7 @@ class CoreObject extends CommonObject { $query[$field] = $this->date_0; } else{ - $query[$field] = $this->db->jdate($this->{$field}); + $query[$field] = $this->db->idate($this->{$field}); } } else if($this->is_array($info)){ @@ -427,7 +427,6 @@ class CoreObject extends CommonObject { } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $this->{$field} = dol_stringtotime($date); } @@ -435,6 +434,7 @@ class CoreObject extends CommonObject { } public function set_values(&$Tab) { + foreach ($Tab as $key=>$value) { if($this->checkFieldType($key,'date')) { diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index da0717e665b..230572050b5 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -355,7 +355,7 @@ abstract class DoliDB implements Database $values[] = $this->quote($v); } - + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.' ( '.implode( ",", $keys ).' ) VALUES ( '.implode( ",", $values ).' ) '; diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 76ed46c4aa8..b02d601854d 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -71,8 +71,9 @@ class Inventory extends CoreObject public $db; - function __construct(DoliDB &$db) + public function __construct(DoliDB &$db) { + global $conf; $this->db = &$db; @@ -85,13 +86,13 @@ class Inventory extends CoreObject } - function sort_det() + private function sort_det() { if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort')); } - function fetch($id,$annexe = true) + public function fetch($id,$annexe = true) { if(!$annexe) $this->withChild = false; @@ -115,7 +116,7 @@ class Inventory extends CoreObject } - function customSort(&$objA, &$objB) + private function customSort(&$objA, &$objB) { global $db; @@ -128,7 +129,7 @@ class Inventory extends CoreObject return $r; } - function changePMP() { + public function changePMP() { foreach ($this->Inventorydet as $k => &$Inventorydet) { @@ -147,7 +148,7 @@ class Inventory extends CoreObject } - function update(User &$user) + public function update(User &$user) { //si on valide l'inventaire on sauvegarde le stock à cette instant @@ -159,7 +160,7 @@ class Inventory extends CoreObject parent::update($user); } - function set_values(&$Tab) + public function set_values(&$Tab) { global $db,$langs; @@ -186,19 +187,19 @@ class Inventory extends CoreObject parent::set_values($Tab); } - function deleteAllLine() { + public function deleteAllLine(User &$user) { foreach($this->Inventorydet as &$det) { $det->to_delete = true; } - $this->update(); + $this->update($user); $this->Inventorydet=array(); } - function add_product($fk_product, $fk_entrepot='') { + public function add_product($fk_product, $fk_entrepot='') { $k = $this->addChild('Inventorydet'); $det = &$this->Inventorydet[$k]; @@ -215,7 +216,7 @@ class Inventory extends CoreObject } - function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') + public function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') { global $conf, $db, $langs, $user; @@ -250,7 +251,7 @@ class Inventory extends CoreObject } } - function regulate() + public function regulate() { global $db,$user,$langs,$conf; @@ -312,6 +313,36 @@ class Inventory extends CoreObject } + public function add_products_for($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0) { + $e = new Entrepot($this->db); + $e->fetch($fk_warehouse); + $TChildWarehouses = array($fk_warehouse); + $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); + + $sql = 'SELECT ps.fk_product, ps.fk_entrepot + FROM '.MAIN_DB_PREFIX.'product_stock ps + INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product) + LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid) + LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid) + WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')'; + + if($fk_category>0) $sql.= " AND cp.fk_categorie=".$fk_category; + if($fk_supplier>0) $sql.= " AND pfp.fk_soc=".$fk_supplier; + if(!empty($only_prods_in_stock)) $sql.= ' AND ps.reel > 0'; + + $sql.=' GROUP BY ps.fk_product, ps.fk_entrepot + ORDER BY p.ref ASC,p.label ASC'; + + $res = $this->db->query($sql); + if($res) { + while($obj = $this->db->fetch_object($res)){ + $this->add_product($obj->fk_product, $obj->fk_entrepot); + } + } + + + } + static function getLink($id) { global $langs,$db; diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index ccda1b37c0e..b03627d326a 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -83,34 +83,7 @@ function _action() $fk_warehouse = (int)GETPOST('fk_warehouse'); $only_prods_in_stock = (int)GETPOST('OnlyProdsInStock'); - $e = new Entrepot($db); - $e->fetch($fk_warehouse); - $TChildWarehouses = array($fk_warehouse); - $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); - - $sql = 'SELECT ps.fk_product, ps.fk_entrepot - FROM '.MAIN_DB_PREFIX.'product_stock ps - INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product) - LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid) - LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid) - WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')'; - - if($fk_category>0) $sql.= " AND cp.fk_categorie=".$fk_category; - if($fk_supplier>0) $sql.= " AND pfp.fk_soc=".$fk_supplier; - if($only_prods_in_stock>0) $sql.= ' AND ps.reel > 0'; - - $sql.=' GROUP BY ps.fk_product, ps.fk_entrepot - ORDER BY p.ref ASC,p.label ASC'; - - - $res = $db->query($sql); - if($res) { - while($obj = $db->fetch_object($res)){ - - $inventory->add_product($obj->fk_product, $obj->fk_entrepot); - } - } - + $inventory->add_products_for($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock); $inventory->update($user); header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=edit', 1)); @@ -134,14 +107,14 @@ function _action() $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch($id); $inventory->set_values($_REQUEST); if ($inventory->errors) { setEventMessage($inventory->errors, 'errors'); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + _card( $inventory, 'edit'); } else { @@ -156,18 +129,18 @@ function _action() $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch($id); if($inventory->status == 0) { $inventory->status = 1; - $inventory->save($PDOdb); + $inventory->update($user); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + _card( $inventory, 'view'); } else { - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + _card( $inventory, 'view'); } break; @@ -181,7 +154,7 @@ function _action() $inventory->changePMP($PDOdb); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view'); + _card( $inventory, 'view'); break; @@ -235,7 +208,7 @@ function _action() $inventory->sort_det(); } - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + _card( $inventory, 'edit'); break; @@ -261,16 +234,16 @@ function _action() if (!$user->rights->inventory->create) accessforbidden(); - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch($id); $inventory->deleteAllLine($PDOdb); setEventMessage('Inventaire vidé'); - _fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit'); + _card( $inventory, 'edit'); break; @@ -278,33 +251,23 @@ function _action() if (!$user->rights->inventory->create) accessforbidden(); - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch($id); - $inventory->delete($PDOdb); + $inventory->delete($user); header('Location: '.dol_buildpath('/inventory/inventory.php', 1)); exit; //_list(); - case 'printDoc': - - $id = __get('id', 0, 'int'); - - $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); - - generateODT($PDOdb, $db, $conf, $langs, $inventory); - break; - case 'exportCSV': - $id = __get('id', 0, 'int'); + $id = GETPOST('id'); $inventory = new Inventory($db); - $inventory->load($PDOdb, $id); + $inventory->fetch($id); exportCSV($inventory); @@ -453,7 +416,7 @@ function _card(&$inventory, $mode='edit') $warehouse = new Entrepot($db); $warehouse->fetch($inventory->fk_warehouse); - print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), '&action='.$mode)); + print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($mode) ? '': '&action='.$mode)); $lines = array(); _card_line($inventory, $lines, $mode); From 1596760d21211d562717467d5043e96d9eda3245 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 17:02:20 +0100 Subject: [PATCH 012/172] fix regulate / apply new PMP / add or remove line --- htdocs/core/class/coreobject.class.php | 24 +++- htdocs/inventory/class/inventory.class.php | 47 ++++---- htdocs/inventory/inventory.php | 129 ++++++++++++++------- htdocs/inventory/tpl/inventory.tpl.php | 26 ++--- 4 files changed, 142 insertions(+), 84 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 50b59761b1d..2022844d6fe 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -35,6 +35,7 @@ class CoreObject extends CommonObject { public $date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ? + public $error = ''; /* * @var Array $_fields Fields to synchronize with Database */ @@ -244,6 +245,8 @@ class CoreObject extends CommonObject { return $this->id; } else { + $this->error = $this->db->lasterror(); + return false; } @@ -335,7 +338,7 @@ class CoreObject extends CommonObject { if(empty($this->id )) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed if(isset($this->to_delete) && $this->to_delete==true) { - $this->delete(); + $this->delete($user); } else { @@ -345,13 +348,21 @@ class CoreObject extends CommonObject { $query['rowid']=$this->id; if(empty($this->no_update_tms))$query['tms'] = date('Y-m-d H:i:s'); - $this->db->update($this->table_element,$query,array('rowid')); + $res = $this->db->update($this->table_element,$query,array('rowid')); - $this->id = $this->db->last_insert_id($this->table_element); + if($res) { + + $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); - $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); + $this->saveChild($user); + + return true; + } + else{ + $this->error = $this->db->lasterror(); - $this->saveChild($user); + return false; + } } return $this->id; @@ -378,6 +389,9 @@ class CoreObject extends CommonObject { return $this->id; } else{ + + $this->error = $this->db->lasterror(); + return false; } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index b02d601854d..b39445807e9 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -86,7 +86,7 @@ class Inventory extends CoreObject } - private function sort_det() + public function sort_det() { if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort')); @@ -129,22 +129,23 @@ class Inventory extends CoreObject return $r; } - public function changePMP() { - - foreach ($this->Inventorydet as $k => &$Inventorydet) - { - - if($Inventorydet->new_pmp>0) { - $Inventorydet->pmp = $Inventorydet->new_pmp; - $Inventorydet->new_pmp = 0; - - $db->query("UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$Inventorydet->pmp." - WHERE rowid = ".$Inventorydet->fk_product ); + public function changePMP(User &$user) { + if(!empty($this->Inventorydet)) { + foreach ($this->Inventorydet as $k => &$Inventorydet) + { + if($Inventorydet->new_pmp>0) { + $Inventorydet->pmp = $Inventorydet->new_pmp; + $Inventorydet->new_pmp = 0; + + $this->db->query("UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$Inventorydet->pmp." + WHERE rowid = ".$Inventorydet->fk_product ); + + } } } - parent::save($PDOdb); + return parent::update($user); } @@ -214,6 +215,7 @@ class Inventory extends CoreObject if(empty($date))$date = $this->get_date('datec', 'Y-m-d'); $det->setStockDate( $date , $fk_entrepot); + return true; } public function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') @@ -233,6 +235,9 @@ class Inventory extends CoreObject $datem = empty($conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT) ? dol_now() : $this->date_inventory; $movementstock=new MouvementStock($db); + $movementstock->origin = new stdClass(); + $movementstock->origin->element = 'inventory'; + $movementstock->origin->id = $this->id; $result=$movementstock->_create($user,$fk_product,$fk_warehouse,$op[$movement],$movement,$price,$label,$inventorycode, $datem); if ($result >= 0) @@ -289,10 +294,7 @@ class Inventory extends CoreObject $href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1); - if(empty($this->title)) - $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock', $href, $this->id)); - else - $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStockWithNomInventaire', $href, $this->title)); + $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock')); } } @@ -304,12 +306,15 @@ class Inventory extends CoreObject return 1; } - public function getNomUrl($picto = 1) { + public function getTitle() { global $langs; - $title = !empty($this->title) ? $this->title : $langs->trans('inventoryTitle').' '.$this->id; - - return ''.($picto ? img_picto('','object_list.png','',0).' ' : '').$title.''; + return !empty($this->title) ? $this->title : $langs->trans('inventoryTitle').' '.$this->id; + } + + public function getNomUrl($picto = 1) { + + return ''.($picto ? img_picto('','object_list.png','',0).' ' : '').$this->getTitle().''; } diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index b03627d326a..5a87eb94ceb 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -77,16 +77,25 @@ function _action() $inventory->set_values($_POST); $fk_inventory = $inventory->create($user); - - $fk_category = (int)GETPOST('fk_category'); - $fk_supplier = (int)GETPOST('fk_supplier'); - $fk_warehouse = (int)GETPOST('fk_warehouse'); - $only_prods_in_stock = (int)GETPOST('OnlyProdsInStock'); + if($fk_inventory>0) { + + $fk_category = (int)GETPOST('fk_category'); + $fk_supplier = (int)GETPOST('fk_supplier'); + $fk_warehouse = (int)GETPOST('fk_warehouse'); + $only_prods_in_stock = (int)GETPOST('OnlyProdsInStock'); + + $inventory->add_products_for($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock); + $inventory->update($user); + + header('Location: '.dol_buildpath('/inventory/inventory.php?id='.$inventory->id.'&action=edit', 1)); + + } + else{ + + setEventMessage($inventory->error,'errors'); + header('Location: '.dol_buildpath('/inventory/inventory.php?action=create', 1)); + } - $inventory->add_products_for($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock); - $inventory->update($user); - - header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=edit', 1)); break; case 'edit': @@ -118,14 +127,14 @@ function _action() } else { - $inventory->save($PDOdb); + $inventory->udpate($user); header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->getId().'&action=view', 1)); } break; - case 'regulate': - + case 'confirm_regulate': + if (!$user->rights->inventory->write) accessforbidden(); $id = GETPOST('id'); $inventory = new Inventory($db); @@ -145,14 +154,14 @@ function _action() break; - case 'changePMP': + case 'confirm_changePMP': $id = GETPOST('id'); $inventory = new Inventory($db); $inventory->fetch( $id ); - $inventory->changePMP($PDOdb); + $inventory->changePMP($user); _card( $inventory, 'view'); @@ -167,35 +176,33 @@ function _action() $inventory = new Inventory($db); $inventory->fetch( $id ); - $type = (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) ? 'string' : 'int'); //AA heu ? - - $fk_product = __get('fk_product', 0, $type); - - if ($fk_product) + $fk_product = GETPOST('fk_product'); + if ($fk_product>0) { $product = new Product($db); - $product->fetch($fk_product); // ! ref TODO vérifier quand même - if($product->type != 0) { + if($product->fetch($fk_product)<=0 || $product->type != 0) { setEventMessage($langs->trans('ThisIsNotAProduct'),'errors'); } else{ //Check product not already exists $alreadyExists = false; - foreach ($inventory->Inventorydet as $invdet) - { - if ($invdet->fk_product == $product->id - && $invdet->fk_warehouse == $fk_warehouse) + if(!empty($inventory->Inventorydet)) { + foreach ($inventory->Inventorydet as $invdet) { - $alreadyExists = true; - break; + if ($invdet->fk_product == $product->id + && $invdet->fk_warehouse == $fk_warehouse) + { + $alreadyExists = true; + break; + } } } - if (!$alreadyExists) { - $inventory->add_product($PDOdb, $product->id, $fk_warehouse); - + if($inventory->add_product($product->id, $fk_warehouse)) { + setEventMessage($langs->trans('ProductAdded')); + } } else { @@ -204,7 +211,7 @@ function _action() } - $inventory->save($PDOdb); + $inventory->update($user); $inventory->sort_det(); } @@ -212,7 +219,7 @@ function _action() break; - case 'delete_line': + case 'confirm_delete_line': if (!$user->rights->inventory->write) accessforbidden(); @@ -230,7 +237,7 @@ function _action() _card($inventory, 'edit'); break; - case 'flush': + case 'confirm_flush': if (!$user->rights->inventory->create) accessforbidden(); @@ -239,15 +246,15 @@ function _action() $inventory = new Inventory($db); $inventory->fetch($id); - $inventory->deleteAllLine($PDOdb); + $inventory->deleteAllLine($user); - setEventMessage('Inventaire vidé'); + setEventMessage($langs->trans('InventoryFlushed')); _card( $inventory, 'edit'); break; - case 'delete': + case 'confirm_delete': if (!$user->rights->inventory->create) accessforbidden(); @@ -258,7 +265,9 @@ function _action() $inventory->delete($user); - header('Location: '.dol_buildpath('/inventory/inventory.php', 1)); + setEventMessage($langs->trans('InventoryDeleted')); + + header('Location: '.dol_buildpath('/inventory/inventory.php?action=list', 1)); exit; //_list(); @@ -407,19 +416,53 @@ function _card_warehouse(&$inventory) llxFooter(''); } -function _card(&$inventory, $mode='edit') +function _card(&$inventory, $action='edit') { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user,$form; llxHeader('',$langs->trans('inventoryEdit'),'',''); + if($action == 'changePMP') { + + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('ApplyNewPMP') + ,$langs->trans('ConfirmApplyNewPMP',$inventory->getTitle()),'confirm_changePMP' + ,array(),'no',1); + + } + else if($action == 'flush') { + + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('FlushInventory') + ,$langs->trans('ConfirmFlushInventory',$inventory->getTitle()),'confirm_flush' + ,array(),'no',1); + + } + else if($action == 'delete') { + + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('Delete') + ,$langs->trans('ConfirmDelete',$inventory->getTitle()),'confirm_delete' + ,array(),'no',1); + + } + else if($action == 'delete_line') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id.'&rowid='.GETPOST('rowid'),$langs->trans('DeleteLine') + ,$langs->trans('ConfirmDeleteLine',$inventory->getTitle()),'confirm_delete_line' + ,array(),'no',1); + + } + else if($action == 'regulate') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('RegulateStock') + ,$langs->trans('ConfirmRegulateStock',$inventory->getTitle()),'confirm_regulate' + ,array(),'no',1); + + } + $warehouse = new Entrepot($db); $warehouse->fetch($inventory->fk_warehouse); - print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($mode) ? '': '&action='.$mode)); + print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action)); $lines = array(); - _card_line($inventory, $lines, $mode); + _card_line($inventory, $lines, $action); print ''.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'

    '; @@ -439,7 +482,7 @@ function _card(&$inventory, $mode='edit') $view_url = dol_buildpath('/inventory/inventory.php', 1); $view = array( - 'mode' => $mode + 'mode' => $action ,'url' => dol_buildpath('/inventory/inventory.php', 1) ,'can_validate' => (int) $user->rights->inventory->validate ,'is_already_validate' => (int) $inventory->status @@ -486,7 +529,7 @@ function _card_line(&$inventory, &$lines, $mode) ,'qty_view' => $Inventorydet->qty_view ? $Inventorydet->qty_view : 0 ,'qty_stock' => $stock ,'qty_regulated' => $Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0 - ,'action' => ($user->rights->inventory->write ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') + ,'action' => ($user->rights->inventory->write && $mode=='edit' ? ''.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'' : '') ,'pmp_stock'=>round($pmp_actual,2) ,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) ,'pmp_new'=>(!empty($user->rights->inventory->changePMP && $mode =='edit') ? ' '.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'' : price($Inventorydet->new_pmp)) diff --git a/htdocs/inventory/tpl/inventory.tpl.php b/htdocs/inventory/tpl/inventory.tpl.php index c3c1347446b..d707ec581b1 100644 --- a/htdocs/inventory/tpl/inventory.tpl.php +++ b/htdocs/inventory/tpl/inventory.tpl.php @@ -159,44 +159,40 @@ } _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actual, $total_current_pa,$total_current_pa_actual); - ?> - - + ?> - + status != 1) { ?>
    - + trans('ExportCSV') ?> trans('Modify') ?> rights->inventory->changePMP)) { - echo ''.$langs->trans('ApplyPMP').''; + echo ''.$langs->trans('ApplyPMP').''; } if ($can_validate == 1) { ?> - Réguler le stock + trans('RegulateStock') ?> - - + + - Vider + trans('Flush'); ?>     - Supprimer + trans('Delete') ?>
    - + status == 1) { ?> From b7a6a71dff921c7bca72fcca7c964fd7b2c0b7a5 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 17:20:46 +0100 Subject: [PATCH 013/172] move file to core --- .../inventory.php} | 26 +-- ...ntory.class.php => modInventory.class.php} | 4 +- htdocs/inventory/lib/inventory.lib.php | 161 +----------------- 3 files changed, 15 insertions(+), 176 deletions(-) rename htdocs/{inventory/admin/inventory_setup.php => admin/inventory.php} (84%) rename htdocs/core/modules/{modinventory.class.php => modInventory.class.php} (99%) diff --git a/htdocs/inventory/admin/inventory_setup.php b/htdocs/admin/inventory.php similarity index 84% rename from htdocs/inventory/admin/inventory_setup.php rename to htdocs/admin/inventory.php index f55bc092517..2548494fc79 100644 --- a/htdocs/inventory/admin/inventory_setup.php +++ b/htdocs/admin/inventory.php @@ -23,17 +23,16 @@ * Put some comments here */ // Dolibarr environment -$res = @include("../../main.inc.php"); // From htdocs directory -if (! $res) { - $res = @include("../../../main.inc.php"); // From "custom" directory -} +require '../main.inc.php'; + // Libraries require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; -require_once '../lib/inventory.lib.php'; +require_once DOL_DOCUMENT_ROOT .'/inventory/lib/inventory.lib.php'; // Translations -$langs->load("inventory@inventory"); +$langs->load("stock"); +$langs->load("inventory"); // Access control if (! $user->admin) { @@ -104,21 +103,6 @@ print ''.$langs->trans("Parameters").''."\n"; print ' '; print ''.$langs->trans("Value").''."\n"; - -// Example with a yes / no select -$var=!$var; -print ''; -print ''.$langs->trans("INVENTORY_GEN_PDF").''; -print ' '; -print ''; -print '
    '; -print ''; -print ''; -print $form->selectyesno("INVENTORY_GEN_PDF",$conf->global->INVENTORY_GEN_PDF,1); -print ''; -print '
    '; -print ''; - // Example with a yes / no select $var=!$var; print ''; diff --git a/htdocs/core/modules/modinventory.class.php b/htdocs/core/modules/modInventory.class.php similarity index 99% rename from htdocs/core/modules/modinventory.class.php rename to htdocs/core/modules/modInventory.class.php index 10fb1cc477e..31170375752 100644 --- a/htdocs/core/modules/modinventory.class.php +++ b/htdocs/core/modules/modInventory.class.php @@ -94,7 +94,7 @@ class modinventory extends DolibarrModules $this->dirs = array(); // Config pages. Put here list of php page, stored into inventory/admin directory, to use to setup module. - $this->config_page_url = array("inventory_setup.php@inventory"); + $this->config_page_url = array("inventory.php"); // Dependencies $this->hidden = false; // A condition to hide module @@ -103,7 +103,7 @@ class modinventory extends DolibarrModules $this->conflictwith = array(); // List of modules id this module is in conflict with $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module - $this->langfiles = array("inventory@inventory"); + $this->langfiles = array("inventory"); // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/inventory/lib/inventory.lib.php b/htdocs/inventory/lib/inventory.lib.php index fd60d631a58..3cbf03a67c7 100644 --- a/htdocs/inventory/lib/inventory.lib.php +++ b/htdocs/inventory/lib/inventory.lib.php @@ -32,14 +32,11 @@ function inventoryAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/inventory/admin/inventory_setup.php", 1); + $head[$h][0] = dol_buildpath("/admin/inventory.php", 1); $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'settings'; $h++; - $head[$h][0] = dol_buildpath("/inventory/admin/inventory_about.php", 1); - $head[$h][1] = $langs->trans("About"); - $head[$h][2] = 'about'; - $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -54,10 +51,12 @@ function inventoryAdminPrepareHead() return $head; } -function inventoryPrepareHead(&$inventory, $title='Inventaire', $get='') +function inventoryPrepareHead(&$inventory, $title='Inventory', $get='') { + global $langs; + return array( - array(dol_buildpath('/inventory/inventory.php?id='.$inventory->id.$get, 1), $title,'inventaire') + array(dol_buildpath('/inventory/inventory.php?id='.$inventory->id.$get, 1), $langs->trans($title),'inventory') ); } @@ -65,7 +64,7 @@ function inventoryPrepareHead(&$inventory, $title='Inventaire', $get='') function inventorySelectProducts(&$inventory) { - global $conf,$db; + global $conf,$db,$langs; $except_product_id = array(); @@ -78,7 +77,6 @@ function inventorySelectProducts(&$inventory) $form = new Form($db); $form->select_produits(-1, 'fk_product'); - // Il nous faut impérativement une liste custom car il ne faut que les entrepôts de la famille de celui qu'on inventorie $TChildWarehouses = array($inventory->fk_warehouse); $e = new Entrepot($db); $e->fetch($inventory->fk_warehouse); @@ -93,153 +91,10 @@ function inventorySelectProducts(&$inventory) $Tab[$res->rowid] = $res->label; } print '   '; - print 'Entrepôt : '.$form::selectarray('fk_warehouse', $Tab); + print $langs->trans('Warehouse').' : '.$form::selectarray('fk_warehouse', $Tab); $select_html = ob_get_clean(); return $select_html; } -function ajaxAutocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array()) -{ - if (empty($minLength)) $minLength=1; - - $script = ''; - - $script.= ''; - - return $script; -} From e65ae08e5cbf926a16ee75c655dc50fe4e955ac0 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 15 Dec 2016 17:42:14 +0100 Subject: [PATCH 014/172] langs --- htdocs/inventory/inventory.php | 7 ++--- htdocs/langs/en_US/inventory.lang | 52 +++++++++++++++++++++++++++++++ htdocs/langs/fr_FR/inventory.lang | 50 +++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 htdocs/langs/en_US/inventory.lang create mode 100644 htdocs/langs/fr_FR/inventory.lang diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index 5a87eb94ceb..d0ca303c239 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -23,8 +23,6 @@ require_once '../main.inc.php'; -ini_set('memory_limit', '512M'); - require_once DOL_DOCUMENT_ROOT.'/core/class/listview.class.php'; require_once DOL_DOCUMENT_ROOT.'/inventory/class/inventory.class.php'; require_once DOL_DOCUMENT_ROOT.'/inventory/lib/inventory.lib.php'; @@ -35,12 +33,11 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -set_time_limit(0); +$langs->load("stock"); +$langs->load("inventory"); if(!$user->rights->inventory->read) accessforbidden(); -$langs->load("inventory"); - _action(); function _action() diff --git a/htdocs/langs/en_US/inventory.lang b/htdocs/langs/en_US/inventory.lang new file mode 100644 index 00000000000..ba947f09d77 --- /dev/null +++ b/htdocs/langs/en_US/inventory.lang @@ -0,0 +1,52 @@ +# Dolibarr language file - Source file is en_US - inventory + +Module104420Name = Inventory +Module104420Desc = Create and manage your inventory + +inventorySetup = Inventory Setup + +inventoryCreatePermission=Create new inventory +inventoryReadPermission=View inventories +inventoryWritePermission=Update inventories +inventoryValidatePermission=Validate inventory + +inventoryTitle=Inventory +inventoryListTitle=List +inventoryListEmpty=No inventory in progress + +inventoryCreateDelete=Create/Delete inventory +inventoryCreate=Create new +inventoryEdit=Edit +inventoryValidate=Validated +inventoryDraft=Running +inventorySelectWarehouse=Warehouse choice +inventoryConfirmCreate=Create +inventoryOfWarehouse=Inventory for warehouse : %s +inventoryErrorQtyAdd=Error : one quantity is leaser than zero +inventoryMvtStock=By inventory +inventoryWarningProductAlreadyExists=This product is already into list +SelectCategory=Category filter +SelectFournisseur=Supplier filter +inventoryOnDate=Inventory +INVENTORY_DISABLE_VIRTUAL=Allow to not destock child product from a kit on inventory +INVENTORY_USE_MIN_PA_IF_NO_LAST_PA=Use the buy price if no last buy price can be found +INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock mouvment have date of inventory +inventoryChangePMPPermission=Allow to change PMP value for a product +ColumnNewPMP=New unit PMP +OnlyProdsInStock=Do not add product without stock +TheoricalQty=Theorique qty +TheoricalValue=Theorique qty +LastPA=Last BP +CurrentPA=Curent BP +RealQty=Real Qty +RealValue=Real Value +RegulatedQty=Regulated Qty +AddInventoryProduct=Add product to inventory +AddProduct=Add +ApplyPMP=Apply PMP +FlushInventory=Flush inventory +ConfirmFlushInventory=Do you confirm this action ? +InventoryFlushed=Inventory flushed +ExitEditMode=Exit edition +inventoryDeleteLine=Delete line +RegulateStock=Regulate Stock \ No newline at end of file diff --git a/htdocs/langs/fr_FR/inventory.lang b/htdocs/langs/fr_FR/inventory.lang new file mode 100644 index 00000000000..85fdf3112dc --- /dev/null +++ b/htdocs/langs/fr_FR/inventory.lang @@ -0,0 +1,50 @@ +Module104420Name = Inventory +Module104420Desc = Create and manage your inventory + +inventorySetup = Inventory Setup + +inventoryCreatePermission=Create new inventory +inventoryReadPermission=View inventories +inventoryWritePermission=Update inventories +inventoryValidatePermission=Validate inventory + +inventoryTitle=Inventory +inventoryListTitle=List +inventoryListEmpty=No inventory in progress + +inventoryCreateDelete=Create/Delete inventory +inventoryCreate=Create new +inventoryEdit=Edit +inventoryValidate=Validated +inventoryDraft=Running +inventorySelectWarehouse=Warehouse choice +inventoryConfirmCreate=Create +inventoryOfWarehouse=Inventory for warehouse : %s +inventoryErrorQtyAdd=Error : one quantity is leaser than zero +inventoryMvtStock=By inventory +inventoryWarningProductAlreadyExists=This product is already into list +SelectCategory=Category filter +SelectFournisseur=Supplier filter +inventoryOnDate=Inventory +INVENTORY_DISABLE_VIRTUAL=Allow to not destock child product from a kit on inventory +INVENTORY_USE_MIN_PA_IF_NO_LAST_PA=Use the buy price if no last buy price can be found +INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock mouvment have date of inventory +inventoryChangePMPPermission=Allow to change PMP value for a product +ColumnNewPMP=New unit PMP +OnlyProdsInStock=Do not add product without stock +TheoricalQty=Theorique qty +TheoricalValue=Theorique qty +LastPA=Last BP +CurrentPA=Curent BP +RealQty=Real Qty +RealValue=Real Value +RegulatedQty=Regulated Qty +AddInventoryProduct=Add product to inventory +AddProduct=Add +ApplyPMP=Apply PMP +FlushInventory=Flush inventory +ConfirmFlushInventory=Do you confirm this action ? +InventoryFlushed=Inventory flushed +ExitEditMode=Exit edition +inventoryDeleteLine=Delete line +RegulateStock=Regulate Stock \ No newline at end of file From 4d375bcf958bed8cffe9b4b56f9fa58f3f669472 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 16 Dec 2016 11:31:14 +0100 Subject: [PATCH 015/172] debug translate --- htdocs/core/class/listview.class.php | 95 +++++++--------------- htdocs/core/js/listview.js | 56 ++++++------- htdocs/core/modules/modInventory.class.php | 11 +-- htdocs/inventory/inventory.php | 17 ++-- htdocs/langs/en_US/inventory.lang | 4 +- htdocs/langs/fr_FR/inventory.lang | 4 +- 6 files changed, 75 insertions(+), 112 deletions(-) diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index e94a648ec27..d276853a362 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -68,7 +68,6 @@ class Listview { $TParam['orderBy'] = $POSTList[$this->id]['orderBy']; } - // print_r($TParam); } private function getSearchNull($key, &$TParam) { return !empty($TParam['search'][$key]['allow_is_null']); @@ -80,7 +79,7 @@ class Listview { if (!is_array($TParam['search'][$key]['table'])) $TParam['search'][$key]['table'] = array($TParam['search'][$key]['table']); foreach ($TParam['search'][$key]['table'] as $prefix_table) { - $TPrefixe[] = '`'.$prefix_table.'`.'; + $TPrefixe[] = $prefix_table.'.'; } } @@ -90,27 +89,18 @@ class Listview { foreach ($TParam['search'][$key]['field'] as $i => $field) { $prefixe = !empty($TPrefixe[$i]) ? $TPrefixe[$i] : $TPrefixe[0]; - $TKey[] = $prefixe.'`'. $field .'`'; + $TKey[] = $prefixe. $field ; } } else { - $TKey[] =$TPrefixe[0].'`'. strtr($key,';','*').'`'; + $TKey[] =$TPrefixe[0].$key; } return $TKey; } - private function getSearchValue($value) { - $value = strtr(trim($value),';','*'); - - return $value; - } private function dateToSQLDate($date) { - list($dd,$mm,$aaaa) = explode('/', substr($date,0,10)); - - $value = date('Y-m-d', mktime(0,0,0,$mm,$dd,$aaaa)); - - return $value; + return $this->db->jdate($date); } private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey, $sBindKey) @@ -118,19 +108,10 @@ class Listview { if(is_array($value)) { - unset($this->TBind[$sBindKey]); - // Si le type de "recherche" est "calendars" on a 2 champs de transmis, [début et fin] ou [que début] ou [que fin] => un BETWEEN Sql serait utile que dans le 1er cas - // donc l'utilisation des opérateur >= et <= permettent un fonctionnement générique $TSQLDate=array(); if(!empty($value['start'])) { $valueDeb = $this->dateToSQLDate($value['start']); - - if(isset($this->TBind[$sBindKey.'_start'])) // TODO can't use this in query case - { - $this->TBind[$sBindKey.'_start'] = $valueDeb; - } - $TSQLDate[]=$sKey." >= '".$valueDeb." 00:00:00'" ; } @@ -138,10 +119,6 @@ class Listview { if(!empty($value['end'])) { $valueFin = $this->dateToSQLDate($value['end']); - if(isset($this->TBind[$sBindKey.'_end'])) { // TODO can't use this in query case - $this->TBind[$sBindKey.'_end'] = $valueFin; - } - $TSQLDate[]=$sKey." <= '".$valueFin." 23:59:59'" ; } @@ -150,25 +127,15 @@ class Listview { } else { - // Sinon je communique une date directement au format d/m/Y et la méthode du dessous reformat en Y-m-d $value = $this->dateToSQLDate($value); - if(isset($this->TBind[$sBindKey])) - { - $this->TBind[$sBindKey] = $value; - } - else - { - // Le % en fin de chaine permet de trouver un resultat si le contenu est au format Y-m-d H:i:s et non en Y-m-d - $TSQLMore[]=$sKey." LIKE '".$value."%'" ; - } + $TSQLMore[]=$sKey." LIKE '".$value."%'" ; + } } private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $sBindKey, $key) { - $value = $this->getSearchValue($value); - if(isset($TParam['operator'][$key])) { if($TParam['operator'][$key] == '<' || $TParam['operator'][$key] == '>' || $TParam['operator'][$key]=='=') @@ -207,7 +174,6 @@ class Listview { foreach($_REQUEST['Listview'][$this->id]['search'] as $key=>$value) { $TsKey = $this->getSearchKey($key, $TParam); - $TsBindKey = $this->getTsBindKey($TsKey); //if (!empty($value)) var_dump($TsKey, $TsBindKey, '=================================='); $TSQLMore = array(); @@ -217,38 +183,32 @@ class Listview { foreach ($TsKey as $i => &$sKey) { - //if (!empty($value)) var_dump($sKey); - $sBindKey = $TsBindKey[$i]; - if($allow_is_null && !empty($_REQUEST['Listview'][$this->id]['search_on_null'][$key])) { - $this->TBind[$sBindKey.'_null'] = $sKey.' IS NULL '; $TSQLMore[] = $sKey.' IS NULL '; $search_on_null = true; - if(isset($this->TBind[$sBindKey])) $this->TBind[$sBindKey]= ''; $value = ''; } elseif($allow_is_null) { - $this->TBind[$sBindKey.'_null'] =0; // $sKey.' IS NOT NULL '; - //$TSQLMore[] = $sKey.' IS NOT NULL '; + null; } if($value!='') { // pas empty car biensûr le statut = 0 existe dans de nombreux cas if(isset($TParam['type'][$key]) && ($TParam['type'][$key]==='date' || $TParam['type'][$key]==='datetime')) { - $this->addSqlFromTypeDate($TSQLMore, $value, $sKey, $sBindKey); + $this->addSqlFromTypeDate($TSQLMore, $value, $sKey); } else { - $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $sBindKey, $key); + $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $key); } } } - if(!isset($this->TBind[$sBindKey]) && !empty($TSQLMore)) + if(!empty($TSQLMore)) { $sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) '; } @@ -282,13 +242,11 @@ class Listview { } private function setSearch(&$THeader, &$TParam) { - global $langs; + global $langs, $form; if(empty($TParam['search'])) return array(); $TSearch=array(); - $form=new TFormCore; - $form->strict_string_compare = true; $nb_search_in_bar = 0; @@ -296,20 +254,22 @@ class Listview { foreach($THeader as $key=>$libelle) { // init if(empty($TSearch[$key]))$TSearch[$key]=''; } - } + } + + $ListPOST = GETPOST('Listview'); + foreach($TParam['search'] as $key=>$param_search) { - - $value = isset($_REQUEST['Listview'][$this->id]['search'][$key]) ? $_REQUEST['Listview'][$this->id]['search'][$key] : ''; + $value = isset($ListPOST[$this->id]['search'][$key]) ? $ListPOST[$this->id]['search'][$key] : ''; $typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search; if(is_array($typeRecherche)) { - $typeRecherche = array(''=>' ') + $typeRecherche; - $fsearch=$form->combo('','Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,0,'',' listviewtbs="combo" init-value="'.$value.'" '); + $fsearch=$form->selectarray('Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,1); } else if($typeRecherche==='calendar') { - $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); + $fsearch = $form->select_date($value, 'Listview['.$this->id.'][search]['.$key.']',0, 0, 1, "", 1, 0, 1); + //$fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); } else if($typeRecherche==='calendars') { $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][start]',isset($value['start'])?$value['start']:'',10,10,' listviewtbs="calendars" ') @@ -340,7 +300,7 @@ class Listview { } - $search_button = ' '.$TParam['liste']['picto_search'].''; + $search_button = ' '.$TParam['liste']['picto_search'].''; if(!empty($TParam['liste']['head_search'])) { $TParam['liste']['head_search'].='
    '.$langs->trans('Search').' '.$search_button.'
    '; @@ -406,8 +366,8 @@ class Listview { private function getJS(&$TParam) { $javaScript = ''; @@ -542,10 +502,13 @@ class Listview { $out.=''; - if(!empty($TParam['liste']['nbSearch'])) { - $out.=' - '.img_search().' - '; + if(count($TSearch)>0) { + $out.=''; + foreach($TSearch as $field=>$search) { + $out.=''.$search.''; + + } + $out.=''; } $out.=''; diff --git a/htdocs/core/js/listview.js b/htdocs/core/js/listview.js index 1157c2ef4b8..03ca7f72508 100644 --- a/htdocs/core/js/listview.js +++ b/htdocs/core/js/listview.js @@ -1,27 +1,27 @@ -var TListTBS_include = true; +var Listview_include = true; -function TListTBS_OrderDown(idListe, column) { +function Listview_OrderDown(idListe, column) { var base_url = document.location.href; - base_url = TListTBS_recup_form_param(idListe,base_url); - base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]'); + base_url = Listview_recup_form_param(idListe,base_url); + base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]'); - base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + base_url = Listview_removeParam(base_url,'get-all-for-export'); - document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC"); + document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC"); } -function TListTBS_OrderUp(idListe, column) { +function Listview_OrderUp(idListe, column) { var base_url = document.location.href; - base_url = TListTBS_recup_form_param(idListe,base_url); - base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]'); + base_url = Listview_recup_form_param(idListe,base_url); + base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]'); - base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + base_url = Listview_removeParam(base_url,'get-all-for-export'); - document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC"); + document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC"); } -function TListTBS_modifyUrl(strURL,paramName,paramNewValue){ +function Listview_modifyUrl(strURL,paramName,paramNewValue){ if (strURL.indexOf(paramName+'=')!=-1){ var strFirstPart=strURL.substring(0,strURL.indexOf(paramName+'=',0))+paramName+'='; @@ -39,7 +39,7 @@ function TListTBS_modifyUrl(strURL,paramName,paramNewValue){ return strURL; } -function TListTBS_removeParam(strURL, paramMask) { +function Listview_removeParam(strURL, paramMask) { var cpt=0; var url = ''; @@ -60,11 +60,11 @@ function TListTBS_removeParam(strURL, paramMask) { return url; } -function TListTBS_recup_form_param(idListe,base_url) { +function Listview_recup_form_param(idListe,base_url) { $('#'+idListe+' tr.barre-recherche [listviewtbs],#'+idListe+' tr.barre-recherche-head input,#'+idListe+' tr.barre-recherche-head select,#'+idListe+' div.tabsAction input[listviewtbs]').each(function(i,item) { if($(item).attr("name")) { - base_url = TListTBS_modifyUrl(base_url, $(item).attr("name") , $(item).val()); + base_url = Listview_modifyUrl(base_url, $(item).attr("name") , $(item).val()); } }); @@ -72,37 +72,37 @@ function TListTBS_recup_form_param(idListe,base_url) { return base_url; } -function TListTBS_GoToPage(idListe,pageNumber){ +function Listview_GoToPage(idListe,pageNumber){ var base_url = document.location.href; - base_url = TListTBS_recup_form_param(idListe,base_url); - base_url =TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][page]",pageNumber); + base_url = Listview_recup_form_param(idListe,base_url); + base_url =Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][page]",pageNumber); - base_url = TListTBS_removeParam(base_url,'get-all-for-export'); + base_url = Listview_removeParam(base_url,'get-all-for-export'); document.location.href=base_url; } -function TListTBS_submitSearch(obj) { +function Listview_submitSearch(obj) { $(obj).closest('form').submit(); - //console.log($(obj).closest('form')); + } -function TListTBS_launch_downloadAs(mode,url,token,session_name) { - $('#listTBSdAS_export_form').remove(); +function Listview_launch_downloadAs(mode,url,token,session_name) { + $('#listviewdAS_export_form').remove(); - $form = $('
    '); + $form = $('
    '); $form.append(''); $form.append(''); $form.append(''); $('body').append($form); - $('#listTBSdAS_export_form').submit(); + $('#listviewdAS_export_form').submit(); } -function TListTBS_downloadAs(obj, mode,url,token,session_name) { +function Listview_downloadAs(obj, mode,url,token,session_name) { $form = $(obj).closest('form'); $div = $form.find('div.tabsAction'); @@ -112,7 +112,7 @@ function TListTBS_downloadAs(obj, mode,url,token,session_name) { $div.append(''); $div.append(''); - TListTBS_submitSearch(obj); + Listview_submitSearch(obj); } $(document).ready(function() { @@ -137,7 +137,7 @@ $(document).ready(function() { }); if(typeof $_GET["get-all-for-export"] != "undefined") { - TListTBS_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]); + Listview_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]); } }); diff --git a/htdocs/core/modules/modInventory.class.php b/htdocs/core/modules/modInventory.class.php index 31170375752..abe65b65647 100644 --- a/htdocs/core/modules/modInventory.class.php +++ b/htdocs/core/modules/modInventory.class.php @@ -66,7 +66,7 @@ class modinventory extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='inventory@inventory'; + $this->picto='inventory'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /inventory/core/xxxxx) (0=disable, 1=enable) @@ -167,8 +167,6 @@ class modinventory extends DolibarrModules // Example: //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); - $langs->load('inventory@inventory'); - // Permissions $this->rights = array(); // Permission array used by this module $r=0; @@ -249,11 +247,11 @@ class modinventory extends DolibarrModules // $r++; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu 'type'=>'left', // This is a Top menu entry - 'titre'=>'Liste des inventaires', + 'titre'=>'ListInventory', 'mainmenu'=>'inventory', 'leftmenu'=>'inventory', 'url'=>'/inventory/inventory.php?action=list', - 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. 'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules @@ -263,11 +261,10 @@ class modinventory extends DolibarrModules $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu 'type'=>'left', // This is a Top menu entry - 'titre'=>'Nouvel inventaire', + 'titre'=>'NewInventory', 'mainmenu'=>'inventory', 'leftmenu'=>'inventory', 'url'=>'/inventory/inventory.php?action=create', - 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. 'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index d0ca303c239..f0a0d073a27 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -266,8 +266,8 @@ function _action() header('Location: '.dol_buildpath('/inventory/inventory.php?action=list', 1)); exit; - //_list(); + break; case 'exportCSV': $id = GETPOST('id'); @@ -309,18 +309,14 @@ function _list() $THide = array('label'); echo $l->render(Inventory::getSQL('All'), array( - 'limit'=>array( - 'nbLine'=>'30' - ) - ,'subQuery'=>array() - ,'link'=>array( + 'link'=>array( 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' ) ,'translate'=>array() ,'hide'=>$THide ,'type'=>array( - 'date_cre'=>'date' - ,'date_maj'=>'datetime' + 'datec'=>'date' + ,'tms'=>'datetime' ,'date_inventory'=>'date' ) ,'liste'=>array( @@ -343,7 +339,10 @@ function _list() ,'eval'=>array( 'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))' ,'rowid'=>'Inventory::getLink(@val@)' - + ) + ,'search'=>array( + 'date_inventory'=>'calendar' + ) )); diff --git a/htdocs/langs/en_US/inventory.lang b/htdocs/langs/en_US/inventory.lang index ba947f09d77..152aceed862 100644 --- a/htdocs/langs/en_US/inventory.lang +++ b/htdocs/langs/en_US/inventory.lang @@ -49,4 +49,6 @@ ConfirmFlushInventory=Do you confirm this action ? InventoryFlushed=Inventory flushed ExitEditMode=Exit edition inventoryDeleteLine=Delete line -RegulateStock=Regulate Stock \ No newline at end of file +RegulateStock=Regulate Stock +ListInventory=Inventories list +NewInventory=New inventory \ No newline at end of file diff --git a/htdocs/langs/fr_FR/inventory.lang b/htdocs/langs/fr_FR/inventory.lang index 85fdf3112dc..546a5202976 100644 --- a/htdocs/langs/fr_FR/inventory.lang +++ b/htdocs/langs/fr_FR/inventory.lang @@ -47,4 +47,6 @@ ConfirmFlushInventory=Do you confirm this action ? InventoryFlushed=Inventory flushed ExitEditMode=Exit edition inventoryDeleteLine=Delete line -RegulateStock=Regulate Stock \ No newline at end of file +RegulateStock=Regulate Stock +InventoryDate=Inventory date +DateUpdate=Last update \ No newline at end of file From 79867a85d05d6730eaa88951c7ab149745efa89e Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 16 Dec 2016 16:09:02 +0100 Subject: [PATCH 016/172] fix list issue --- htdocs/core/class/listview.class.php | 74 +++++++-------- htdocs/core/js/listview.js | 10 +- htdocs/core/modules/modInventory.class.php | 2 +- htdocs/inventory/class/inventory.class.php | 2 +- htdocs/inventory/inventory.php | 68 +------------- htdocs/inventory/list.php | 103 +++++++++++++++++++++ 6 files changed, 152 insertions(+), 107 deletions(-) create mode 100644 htdocs/inventory/list.php diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index d276853a362..6b57fd36a21 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -40,7 +40,7 @@ class Listview { if(!isset($TParam['link']))$TParam['link']=array(); if(!isset($TParam['type']))$TParam['type']=array(); if(!isset($TParam['orderby']['noOrder']))$TParam['orderby']['noOrder']=array(); - if(!isset($TParam['no-select'])) $TParam['no-select'] = 1; + if(!isset($TParam['allow-fields-select'])) $TParam['allow-fields-select'] = 0; if(!isset($TParam['list']))$TParam['list']=array(); $TParam['list'] = array_merge(array( @@ -53,7 +53,7 @@ class Listview { ,'orderUp'=>'' ,'id'=>$this->id ,'head_search'=>'' - ,'export'=>array() + ,'export'=>array() //TODO include native export ,'view_type'=>'' //TODO to include graph or kanban instead of list ),$TParam['list']); @@ -133,7 +133,7 @@ class Listview { } } - private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $sBindKey, $key) + private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key) { if(isset($TParam['operator'][$key])) @@ -272,38 +272,40 @@ class Listview { //$fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" '); } else if($typeRecherche==='calendars') { - $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][start]',isset($value['start'])?$value['start']:'',10,10,' listviewtbs="calendars" ') - .' '.$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][end]',isset($value['end'])?$value['end']:'',10,10,' listviewtbs="calendars" '); + + $fsearch = $form->select_date(isset($value['start'])?$value['start']:'', 'Listview['.$this->id.'][search]['.$key.'][start]',0, 0, 1, "", 1, 0, 1) + . $form->select_date(isset($value['end'])?$value['end']:'', 'Listview['.$this->id.'][search]['.$key.'][end]',0, 0, 1, "", 1, 0, 1); + } else if(is_string($typeRecherche)) { $fsearch=$TParam['search'][$key]; } else { - $fsearch=$form->texte('','Listview['.$this->id.'][search]['.$key.']',$value,15,255,' listviewtbs="input" '); + $fsearch=''; } if(!empty($param_search['allow_is_null'])) { - $valueNull = isset($_REQUEST['Listview'][$this->id]['search_on_null'][$key]) ? 1 : 0; + $valueNull = isset($ListPOST[$this->id]['search_on_null'][$key]) ? 1 : 0; $fsearch.=' '.$form->checkbox1('', 'Listview['.$this->id.'][search_on_null]['.$key.']',1, $valueNull,' onclick=" if($(this).is(\':checked\')){ $(this).prev().val(\'\'); }" ').img_help(1, $langs->trans('SearchOnNUllValue')); } - if(!empty($THeader[$key]) || $this->getViewType($TParam) == 'chart') { + if(!empty($THeader[$key])) { $TSearch[$key] = $fsearch; $nb_search_in_bar++; } else { - $libelle = !empty($TParam['title'][$key]) ? $TParam['title'][$key] : $key ; - $TParam['liste']['head_search'].='
    '.$libelle.' '.$fsearch.'
    '; + $label = !empty($TParam['title'][$key]) ? $TParam['title'][$key] : $key ; + $TParam['list']['head_search'].='
    '.$libelle.' '.$fsearch.'
    '; } } - $search_button = ' '.$TParam['liste']['picto_search'].''; + $search_button = ' '.img_search().''; - if(!empty($TParam['liste']['head_search'])) { - $TParam['liste']['head_search'].='
    '.$langs->trans('Search').' '.$search_button.'
    '; + if(!empty($TParam['list']['head_search'])) { + $TParam['list']['head_search']='
    '.$search_button.'
    '.$TParam['list']['head_search']; } if($nb_search_in_bar>0) { @@ -364,7 +366,7 @@ class Listview { return array($TTotal,$TTotalGroup); } - private function getJS(&$TParam) { + private function getJS() { $javaScript = ' -status != 1) { ?> +status != 1) { ?> trans('AddInventoryProduct'); ?> :
    - + - + - +
    @@ -90,7 +90,7 @@ - +
    - status != 1) { ?> + status != 1) { ?> - status == 1) { ?> + status == 1) { ?> -

    Date de création : getDate('datec') ?> -
    Dernière mise à jour : getDate('tms') ?>

    +

    Date de création : getDate('datec') ?> +
    Dernière mise à jour : getDate('tms') ?>

    From b57bf6460bd6f73339030ad83ed35de6d6843056 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 02:34:00 +0200 Subject: [PATCH 084/172] Start debug inventory --- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../install/mysql/tables/llx_inventorydet.sql | 2 +- htdocs/product/inventory/card.php | 19 ++++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 4a383fcb505..b20da8b9b89 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -204,7 +204,7 @@ tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, -entity integer DEFAULT 0, +batch varchar(30) DEFAULT NULL, qty_view double DEFAULT 0, qty_stock double DEFAULT 0, qty_regulated double DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_inventorydet.sql b/htdocs/install/mysql/tables/llx_inventorydet.sql index 20e48b877b5..2b203e0c58b 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet.sql @@ -25,7 +25,7 @@ tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, -entity integer DEFAULT 0, +batch varchar(30) DEFAULT NULL, -- Lot or serial number qty_view double DEFAULT 0, qty_stock double DEFAULT 0, qty_regulated double DEFAULT 0, diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index e89a59bb505..f7e4cbecb0a 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -146,12 +146,13 @@ if (empty($reshook)) if ($object->errors) { setEventMessage($object->errors, 'errors'); - card( $object, 'edit'); + $action = 'edit'; } else { $object->udpate($user); header('Location: '.dol_buildpath('/product/inventory/card.php?id='.$object->getId().'&action=view', 1)); + exit; } break; @@ -167,12 +168,10 @@ if (empty($reshook)) $object->status = 1; $object->update($user); - card( $object, 'view'); - - + $action='view'; } else { - card( $object, 'view'); + $action='view'; } break; @@ -186,7 +185,7 @@ if (empty($reshook)) $object->changePMP($user); - card( $object, 'view'); + $action='view'; break; @@ -238,7 +237,7 @@ if (empty($reshook)) $object->sortDet(); } - card( $object, 'edit'); + $action='edit'; break; @@ -257,7 +256,7 @@ if (empty($reshook)) $object = new Inventory($db); $object->fetch( $id); - card($object, 'edit'); + $action='edit'; break; case 'confirm_flush': @@ -273,14 +272,12 @@ if (empty($reshook)) setEventMessage($langs->trans('InventoryFlushed')); - card( $object, 'edit'); - + $action='edit'; break; case 'confirm_delete': if (!$user->rights->stock->supprimer) accessforbidden(); - $id = GETPOST('id'); $object = new Inventory($db); From 865c8140d1bf0900d59906de1b01f4416d360b1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 03:18:49 +0200 Subject: [PATCH 085/172] Clean code --- ChangeLog | 4 +- htdocs/comm/propal/contact.php | 4 +- htdocs/commande/contact.php | 5 +- htdocs/core/class/commonobject.class.php | 119 +++++++++--------- htdocs/core/lib/company.lib.php | 49 ++++++++ htdocs/expedition/contact.php | 4 +- htdocs/expedition/shipment.php | 4 +- .../skeletons/skeleton_class.class.php | 49 +++++--- htdocs/product/card.php | 77 ++++++------ htdocs/societe/class/societe.class.php | 12 -- htdocs/societe/societecontact.php | 5 +- 11 files changed, 197 insertions(+), 135 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31ddbd56bdd..3eb284ccc80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,9 @@ Following changes may create regression for some external modules, but were nece * The page compta/facture.php was renamed into compta/facture/card.php to match page naming conventions. * The signature of method ->delete() of class Product and PriceExpression was changed from ->delete($id, notrigger) to ->delete(User, notrigger) to match standard dev rules. - +* Removed CommonObject::displayMarginInfos (was deprecated in 3.8). Use same method into + html.formmargin.class.php +* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. ***** ChangeLog for 5.0.1 compared to 5.0.0 ***** FIX: #6503: SQL error in "Last pending payment invoices" diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 3c3aa6aef88..3e9e5a1205d 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -130,12 +130,12 @@ else if ($action == 'deletecontact' && $user->rights->propale->creer) dol_print_error($db); } } - +/* else if ($action == 'setaddress' && $user->rights->propale->creer) { $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); -} +}*/ /* diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index bc257f3ac05..fe37a630c5d 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -107,13 +107,14 @@ else if ($action == 'deletecontact' && $user->rights->commande->creer) dol_print_error($db); } } - +/* else if ($action == 'setaddress' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); -} +}*/ + /* * View diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e03db1b4773..2526638cee5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -238,6 +238,7 @@ abstract class CommonObject /** * @var int Delivery address ID + * @deprecated * @see setDeliveryAddress() */ public $fk_delivery_address; @@ -1623,7 +1624,8 @@ abstract class CommonObject /** * Define delivery address - * + * @deprecated + * * @param int $id Address id * @return int <0 si ko, >0 si ok */ @@ -3223,51 +3225,14 @@ abstract class CommonObject /** * Return if a country is inside the EEC (European Economic Community) - * TODO Add a field into dictionary + * @deprecated * * @return boolean true = country inside EEC, false = country outside EEC */ function isInEEC() { - // List of all country codes that are in europe for european vat rules - // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta - //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom - //'CH', // Switzerland - No. Swizerland in not in EEC - ); - //print "dd".$this->country_code; - return in_array($this->country_code,$country_code_in_EEC); + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + return isInEEC($this); } @@ -3754,21 +3719,6 @@ abstract class CommonObject } - /** - * Show the array with all margin infos - * - * @param bool $force_price Force price - * @return void - * @deprecated 3.8 Load FormMargin class and make a direct call to displayMarginInfos - */ - function displayMarginInfos($force_price=false) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; - $formmargin=new FormMargin($this->db); - $formmargin->displayMarginInfos($this, $force_price); - } - - /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4711,4 +4661,61 @@ abstract class CommonObject } return $buyPrice; } + + + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function createCommon(User $user, $notrigger = false) + { + + } + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchCommon($id, $ref = null) + { + + } + + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function updateCommon(User $user, $notrigger = false) + { + + } + + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function deleteCommon(User $user, $notrigger = false) + { + + } } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 809a045bacf..6847cd7b9c2 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -496,6 +496,55 @@ function getFormeJuridiqueLabel($code) } } +/** + * Return if a country is inside the EEC (European Economic Community) + * TODO Add a field into country dictionary. + * + * @param Object $object Object + * @return boolean true = country inside EEC, false = country outside EEC + */ +function isInEEC($object) +{ + // List of all country codes that are in europe for european vat rules + // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 + $country_code_in_EEC=array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta + //'NO', // Norway + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom + //'CH', // Switzerland - No. Swizerland in not in EEC + ); + //print "dd".$this->country_code; + return in_array($object->country_code, $country_code_in_EEC); +} /** diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 1354b3d49f1..7c721d7cf47 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -123,13 +123,13 @@ else if ($action == 'deletecontact' && $user->rights->expedition->creer) dol_print_error($db); } } - +/* else if ($action == 'setaddress' && $user->rights->expedition->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); -} +}*/ /* diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 57ad04a8a1a..ede1cc6bec9 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -113,7 +113,7 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + /* if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) { $object = new Commande($db); @@ -122,7 +122,7 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + */ if ($action == 'setmode' && $user->rights->commande->creer) { $object = new Commande($db); diff --git a/htdocs/modulebuilder/skeletons/skeleton_class.class.php b/htdocs/modulebuilder/skeletons/skeleton_class.class.php index 01b48c35f75..6805a697043 100644 --- a/htdocs/modulebuilder/skeletons/skeleton_class.class.php +++ b/htdocs/modulebuilder/skeletons/skeleton_class.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud @@ -20,10 +20,9 @@ */ /** - * \file dev/skeletons/skeleton_class.class.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - * Put some comments here + * \file modulebuilder/skeletons/skeleton_class.class.php + * \ingroup mymodule othermodule1 othermodule2 + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) */ // Put here all includes required by your class file @@ -34,26 +33,27 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; /** * Class Skeleton_Class * - * Put here description of your class - * - * @see CommonObject + * Put here description of your class. */ class Skeleton_Class extends CommonObject { /** - * @var string Id to identify managed objects + * @var string Id to identify managed object */ public $element = 'skeleton'; /** * @var string Name of table without prefix where object is stored */ public $table_element = 'skeleton'; - - /** - * @var Skeleton_ClassLine[] Lines - */ - public $lines = array(); - + /** + * @var array Array with all fields and their property + */ + public $picto = 'generic'; + /** + * @var array Array with all fields and their property + */ + public $fields; + /** * @var mixed Sample property 1 */ @@ -62,8 +62,21 @@ class Skeleton_Class extends CommonObject * @var mixed Sample property 2 */ public $prop2; + //... - + + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + public $table_element_line = 'skeletondet'; + public $class_element_line = 'SkeletonLine'; + public $fk_element = 'fk_skeleton'; + /** + * @var Skeleton_ClassLine[] Lines + */ + public $lines = array(); + + + /** * Constructor * @@ -289,10 +302,10 @@ class Skeleton_Class extends CommonObject */ public function update(User $user, $notrigger = false) { - $error = 0; - dol_syslog(__METHOD__, LOG_DEBUG); + $error = 0; + // Clean parameters if (isset($this->prop1)) { $this->prop1 = trim($this->prop1); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 536bcece10f..71f7cd8e7f6 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1801,60 +1801,61 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf-> /* Barre d'action */ /* */ /* ************************************************************************** */ - -print "\n".'
    '."\n"; - -$parameters=array(); -$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) +if ($action != 'create' && $action != 'edit') { - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || - ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) + print "\n".'
    '."\n"; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; - - if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || + ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) { - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) + if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; + + if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) { - print '
    '.$langs->trans('ToClone').'
    '."\n"; - } - else - { - print ''; + if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) + { + print '
    '.$langs->trans('ToClone').'
    '."\n"; + } + else + { + print ''; + } } } - } - $object_is_used = $object->isObjectUsed($object->id); - - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) - || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) - { - if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) + $object_is_used = $object->isObjectUsed($object->id); + + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) + || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) + if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) { - print '
    '.$langs->trans('Delete').'
    '."\n"; + if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) + { + print '
    '.$langs->trans('Delete').'
    '."\n"; + } + else + { + print ''; + } } else - { - print ''; + { + print ''; } } else - { - print ''; + { + print ''; } } - else - { - print ''; - } + + print "\n
    \n"; } -print "\n
    \n"; - - /* * All the "Add to" areas */ @@ -1974,7 +1975,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = * Documents generes */ -if ($action != 'edit' && $action != 'delete') +if ($action != 'create' && $action != 'edit' && $action != 'delete') { print '
    '; print ''; // ancre diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 74aef09e7a9..0581ed1960e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3326,18 +3326,6 @@ class Societe extends CommonObject return "Error, mode/status not found"; } - /** - * Set commnunication level - * - * @param User $user User making change - * @return int <0 if KO, >0 if OK - * @deprecated Use update function instead - */ - function set_commnucation_level($user) - { - return $this->update($this->id, $user); - } - /** * Set outstanding value * diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 2bda75867dc..b5ffc87517f 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -107,13 +107,14 @@ else if ($action == 'deletecontact' && $user->rights->societe->creer) dol_print_error($db); } } - +/* else if ($action == 'setaddress' && $user->rights->societe->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); -} +}*/ + /* * View From 60951cf30743e0fb12a1991aae063b6eeba8c7b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 04:09:50 +0200 Subject: [PATCH 086/172] Less data example --- htdocs/admin/dict.php | 7 ++++--- htdocs/core/menus/standard/eldy.lib.php | 2 +- .../mysql/data/llx_c_hrm_department.sql | 18 +++++++----------- htdocs/langs/en_US/admin.lang | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 125f913eb8d..d4aa0ce6989 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1073,7 +1073,7 @@ if ($id) print ''; // Line to enter new values - print ''; + print ''; $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. @@ -1814,13 +1814,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field]=='affect') $class='maxwidth50'; if ($fieldlist[$field]=='delay') $class='maxwidth50'; if ($fieldlist[$field]=='position') $class='maxwidth50'; - if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent'; + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $class='quatrevingtpercent'; if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent'; if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $class='maxwidth50'; print ''; $transfound=0; if (in_array($fieldlist[$field], array('label','libelle'))) { + $transkey=''; // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_civility') { $transkey="Civility".strtoupper($obj->code); @@ -1829,7 +1830,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $langs->load("bills"); $transkey="PaymentCondition".strtoupper($obj->code); } - if ($langs->trans($transkey) != $transkey) + if ($transkey && $langs->trans($transkey) != $transkey) { $transfound=1; print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1e88601604f..dffc5f9af1b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -545,7 +545,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"),1); $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); - $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1, $conf->global->MAIN_FEATURES_LEVEL); + $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"),1); $newmenu->add("/admin/delais.php?mainmenu=home",$langs->trans("MenuWarnings"),1); $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"),1); diff --git a/htdocs/install/mysql/data/llx_c_hrm_department.sql b/htdocs/install/mysql/data/llx_c_hrm_department.sql index e6e4921f372..c4865ad9e30 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_department.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_department.sql @@ -24,20 +24,16 @@ -- INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(2, 10,'GESTION', 'Gestion', 1); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(3, 15,'TRAINING', 'Training', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(4, 20,'IT', 'Inform. Technology (IT)', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(5, 25,'MARKETING', 'Marketing', 1); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(4, 20,'IT', 'Inform. Technology (IT)', 0); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(5, 25,'MARKETING', 'Marketing', 0); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(6, 30,'SALES', 'Sales', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(7, 35,'LEGAL', 'Legal', 1); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(7, 35,'LEGAL', 'Legal', 0); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(8, 40,'FINANCIAL', 'Financial accounting', 1); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(9, 45,'HUMANRES', 'Human resources', 1); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(10, 50,'PURCHASING', 'Purchasing', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(11, 55,'SERVICES', 'Services', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(12, 60,'CUSTOMSERV', 'Customer service', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(13, 65,'CONSULTING', 'Consulting', 1); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(12, 60,'CUSTOMSERV', 'Customer service', 0); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(14, 70,'LOGISTIC', 'Logistics', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(15, 75,'CONSTRUCT', 'Engineering/design', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(16, 80,'PRODUCTION', 'Manufacturing', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(17, 85,'QUALITY', 'Quality assurance', 1); -INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(18, 85,'MAINT', 'Plant assurance', 1); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(15, 75,'CONSTRUCT', 'Engineering/design', 0); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(16, 80,'PRODUCTION', 'Production', 1); +INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(17, 85,'QUALITY', 'Quality assurance', 0); \ No newline at end of file diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 69c72fc7aad..02ff5740986 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -432,7 +432,7 @@ PageUrlForDefaultValues=You must enter here the relative url of the page. If you PageUrlForDefaultValuesCreate=
    For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
    For page that list thirdparties, it is %s GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. -WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order to retreive default behavior. +WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field # Modules Module0Name=Users & groups From a9eeb823bd25d81f1979db1a99f92fd16328b522 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 04:32:03 +0200 Subject: [PATCH 087/172] Fix browser notif --- htdocs/admin/agenda.php | 2 +- htdocs/admin/agenda_extrafields.php | 2 +- htdocs/admin/agenda_extsites.php | 2 +- htdocs/admin/agenda_other.php | 2 +- htdocs/admin/agenda_xcal.php | 2 +- htdocs/core/ajax/check_notifications.php | 7 ++++++- htdocs/core/js/lib_notification.js.php | 12 +++++++----- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index d076fcf7e26..c5fc1c55793 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -144,7 +144,7 @@ print ''; $head=agenda_prepare_head(); -dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), 0, 'action'); +dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); print $langs->trans("AgendaAutoActionDesc")."
    \n"; print $langs->trans("OnlyActiveElementsAreShown").'
    '; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 2cf3a323c21..74ae6cb2d95 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -75,7 +75,7 @@ print "
    \n"; $head=agenda_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), 0, 'action'); +dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 1e595b5088e..0b69b947a38 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -137,7 +137,7 @@ print ''; $head=agenda_prepare_head(); -dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), 0, 'action'); +dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); print $langs->trans("AgendaExtSitesDesc")."
    \n"; print "
    \n"; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 6e0a62610aa..f652829a80c 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -196,7 +196,7 @@ print "
    \n"; $head=agenda_prepare_head(); -dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action'); +dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); /* diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index cd2406e6fdc..0e66125ba7c 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -83,7 +83,7 @@ print ''; $head=agenda_prepare_head(); -dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), 0, 'action'); +dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action'); print $langs->trans("AgendaSetupOtherDesc")."
    \n"; print "
    \n"; diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 4db67aef939..fa3edd7a4be 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -21,7 +21,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; @@ -88,9 +87,11 @@ if ($time >= $_SESSION['auto_check_events_not_before']) while ($obj = $db->fetch_object($resql)) { $langs->load("agenda"); + $langs->load("commercial"); $actionmod->fetch($obj->id); + // Message must be formated and translated to be used with javascript directly $event = array(); $event['type'] = 'agenda'; $event['id'] = $actionmod->id; @@ -101,6 +102,10 @@ if ($time >= $_SESSION['auto_check_events_not_before']) $eventfound[] = $event; } } + else + { + dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); + } } diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index af4452dfb39..a3b90a35db6 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -65,7 +65,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. var time_first_execution = (time_auto_update - (nowtime - time_js_next_test)) * 1000; //need milliseconds if (login != '') { - console.log("Launch browser notif check: setTimeout to wait time_first_execution="+time_first_execution+" before first check - nowtime = "+nowtime+" auto_check_events_not_before = "+auto_check_events_not_before+" time_js_next_test = "+time_js_next_test+" time_auto_update="+time_auto_update); + console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" auto_check_events_not_before (val in session)= "+auto_check_events_not_before+" time_js_next_test (max now,auto_check_events_not_before) = "+time_js_next_test+" time_auto_update="+time_auto_update); setTimeout(first_execution, time_first_execution); } //first run auto check @@ -79,17 +79,18 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H function check_events() { if (Notification.permission === "granted") { - console.log("Call check_events time_js_next_test="+time_js_next_test); - $.ajax("", { - type: "post", // Usually post o get + console.log("Call check_events time_js_next_test = date we are looking for event after ="+time_js_next_test); + $.ajax("", { + type: "post", // Usually post or get async: true, data: {time: time_js_next_test}, success: function (result) { var arr = JSON.parse(result); if (arr.length > 0) { + var audio = null; global->AGENDA_NOTIFICATION_SOUND)) { - print 'var audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');'; + print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');'; } ?> @@ -136,6 +137,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H } time_js_next_test += time_auto_update; + console.log('Updated time_js_next_test. New value is '+time_js_next_test); } Date: Sun, 30 Apr 2017 07:41:47 +0200 Subject: [PATCH 088/172] Correct multi-journals --- htdocs/accountancy/admin/journals_card.php | 12 +++++++----- .../admin/{journals.php => journals_list.php} | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) rename htdocs/accountancy/admin/{journals.php => journals_list.php} (97%) diff --git a/htdocs/accountancy/admin/journals_card.php b/htdocs/accountancy/admin/journals_card.php index 9e04d75ce9f..aae3f8b2cb1 100644 --- a/htdocs/accountancy/admin/journals_card.php +++ b/htdocs/accountancy/admin/journals_card.php @@ -64,7 +64,7 @@ $object = new AccountingJournal($db); if ($action == 'confirm_delete' && $confirm == "yes") { $result = $object->delete($id); if ($result >= 0) { - header("Location: journals.php"); + header("Location: journals_list.php"); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -108,7 +108,7 @@ else if ($action == 'add') { $action = 'create'; } } else { - header("Location: ./journals.php"); + header("Location: journals_list.php"); exit(); } } @@ -227,7 +227,9 @@ if ($action == 'create') print ''; - print '
    '; + dol_fiche_end(); + + print '
    '; print ''; print '     '; print ''; @@ -248,7 +250,7 @@ if ($action == 'create') print ''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; // Ref print ''; + } + elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + print ''; + } + else + { + print ''; + } + } +} \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index d7cc61d6418..064f56bddd6 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -82,208 +82,6 @@ class AccountingJournal extends CommonObject } } - /** - * Insert journal in database - * - * @param User $user Use making action - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - function create($user, $notrigger = 0) - { - global $conf; - $error = 0; - $now = dol_now(); - - // Clean parameters - if (isset($this->code)) - $this->code = trim($this->code); - if (isset($this->label)) - $this->label = trim($this->label); - - // Check parameters - if (empty($this->nature) || $this->nature == '-1') - { - $this->nature = '0'; - } - - // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_journal("; - $sql .= "code"; - $sql .= ", label"; - $sql .= ", nature"; - $sql .= ", active"; - $sql .= ") VALUES ("; - $sql .= " " . (empty($this->code) ? 'NULL' : "'" . $this->db->escape($this->code) . "'"); - $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); - $sql .= ", " . (empty($this->nature) ? '0' : "'" . $this->db->escape($this->nature) . "'"); - $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active)); - $sql .= ")"; - - $this->db->begin(); - - dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_journal"); - - // if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - // } - } - - // Commit or rollback - if ($error) { - foreach ( $this->errors as $errmsg ) { - dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } - - /** - * Update record - * - * @param User $user Use making update - * @return int <0 if KO, >0 if OK - */ - function update($user) - { - // Check parameters - if (empty($this->nature) || $this->nature == '-1') - { - $this->nature = '0'; - } - - $this->db->begin(); - - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal "; - $sql .= " SET code = " . ($this->code ? "'" . $this->db->escape($this->code) . "'" : "null"); - $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); - $sql .= " , nature = " . ($this->nature ? "'" . $this->db->escape($this->nature) . "'" : "0"); - $sql .= " , active = '" . $this->active . "'"; - $sql .= " WHERE rowid = " . $this->id; - - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return - 1; - } - } - - /** - * Check usage of accounting journal - * - * @return int <0 if KO, >0 if OK - */ - function checkUsage() { - global $langs; - - $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - $sql .= "UNION"; - $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - - dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num > 0) { - $this->error = $langs->trans('ErrorAccountingJournalIsAlreadyUse'); - return 0; - } else { - return 1; - } - } else { - $this->error = $this->db->lasterror(); - return - 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param int $notrigger 0=triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger = 0) { - $error = 0; - - $result = $this->checkUsage(); - - if ($result > 0) { - - $this->db->begin(); - - // if (! $error) { - // if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - // } - // } - - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_journal"; - $sql .= " WHERE rowid=" . $this->id; - - dol_syslog(get_class($this) . "::delete sql=" . $sql); - $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { - foreach ( $this->errors as $errmsg ) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return 1; - } - } else { - return - 1; - } - } - /** * Return clicable name (with picto eventually) * @@ -311,64 +109,6 @@ class AccountingJournal extends CommonObject return $result; } - /** - * Deactivate journal - * - * @param int $id Id - * @return int <0 if KO, >0 if OK - */ - function journal_deactivate($id) { - $result = $this->checkUsage(); - - if ($result > 0) { - $this->db->begin(); - - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal "; - $sql .= "SET active = '0'"; - $sql .= " WHERE rowid = " . $this->db->escape($id); - - dol_syslog(get_class($this) . "::deactivate sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - - if ($result) { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return - 1; - } - } else { - return - 1; - } - } - - /** - * Activate journal - * - * @param int $id Id - * @return int <0 if KO, >0 if OK - */ - function journal_activate($id) { - $this->db->begin(); - - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal "; - $sql .= "SET active = '1'"; - $sql .= " WHERE rowid = " . $this->db->escape($id); - - dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return - 1; - } - } - - /** * Retourne le libelle du statut d'un user (actif, inactif) * diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 54cddfcaa96..9106c345fda 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -211,14 +211,15 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 22, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__); -- Binding insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f715061d562..aa905b4ef93 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -952,7 +952,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Chart of account if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=33&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 20); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 30); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 31); diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index 5f0e8dd5416..c468e4c3968 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -31,10 +31,10 @@ delete from llx_accounting_account; delete from llx_accounting_system; delete from llx_accounting_journal; -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 1, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 2, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 3, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 0, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 2, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 3, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 4, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 1, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1); -- -- Descriptif des plans comptables FR PCG99-ABREGE diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql index d9c6ea76e3e..bccfb234c3e 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql @@ -22,6 +22,6 @@ create table llx_accounting_journal rowid integer AUTO_INCREMENT PRIMARY KEY, code varchar(32) NOT NULL, label varchar(128) NOT NULL, - nature smallint DEFAULT 0 NOT NULL, -- type of journals (0:various operations / 1:sale / 2:purchase / 3:bank / 9: has-new) + nature smallint DEFAULT 0 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) active smallint DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index bd1e41c5464..84ac021d041 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -204,11 +204,11 @@ NewAccountingJournal=New accounting journal ShowAccoutingJournal=Show accounting journal Code=Code Nature=Nature -AccountingJournalTypeVariousOperation=Various operation -AccountingJournalTypeSale=Sale -AccountingJournalTypePurchase=Purchase -AccountingJournalTypeBank=Bank -AccountingJournalTypeHasNew=Has-new +AccountingJournalType1=Various operation +AccountingJournalType2=Sales +AccountingJournalType3=Purchases +AccountingJournalType4=Bank +AccountingJournalType9=Has-new ErrorAccountingJournalIsAlreadyUse=This journal is already use ## Export diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 02ff5740986..e432a57bb9d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -856,6 +856,7 @@ DictionaryOrderMethods=Ordering methods DictionarySource=Origin of proposals/orders DictionaryAccountancyCategory=Accounting account groups DictionaryAccountancysystem=Models for chart of accounts +DictionaryAccountancyJournal=Accounting journals DictionaryEMailTemplates=Emails templates DictionaryUnits=Units DictionaryProspectStatus=Prospection status From 5af5c23a987f9d0025653da691120c6e8e3516e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 May 2017 12:46:40 +0200 Subject: [PATCH 096/172] Look and feel v6 --- .../core/tpl/admin_extrafields_view.tpl.php | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index c14927ec048..3242a388a3d 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2017 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -49,23 +49,36 @@ if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''; print "\n"; -$var=True; -foreach($extrafields->attribute_type as $key => $value) +if (count($extrafields->attribute_type)) { + foreach($extrafields->attribute_type as $key => $value) + { + + print ''; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '\n"; // Add hidden option on not working feature. Why hide if user can't see it. + print '\n"; + print ""; + } +} +else +{ + $colspan=9; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++; print ''; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print '\n"; - print '\n"; - print '\n"; - print '\n"; - if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '\n"; // Add hidden option on not working feature. Why hide if user can't see it. - print '\n"; - print ""; + print ''; + print ''; } print "
    ' . $langs->trans("Code") . ''; @@ -271,7 +273,7 @@ if ($action == 'create') dol_fiche_end(); - if (! empty($user->rights->accounting->fiscalyear)) + if (! empty($user->rights->accounting->chartofaccount)) { /* * Barre d'actions diff --git a/htdocs/accountancy/admin/journals.php b/htdocs/accountancy/admin/journals_list.php similarity index 97% rename from htdocs/accountancy/admin/journals.php rename to htdocs/accountancy/admin/journals_list.php index 677f2a743e5..f7ba79457a8 100644 --- a/htdocs/accountancy/admin/journals.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/accountancy/admin/journals.php + * \file htdocs/accountancy/admin/journals_list.php * \ingroup Advanced accountancy * \brief Setup page to configure journals */ @@ -154,7 +154,7 @@ dol_fiche_end(); // Buttons print '
    '; -if (! empty($user->rights->accounting->fiscalyear)) +if (! empty($user->rights->accounting->chartofaccount)) { print '' . $langs->trans("NewAccountingJournal") . ''; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index dffc5f9af1b..f715061d562 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -165,7 +165,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->loan->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), 'module'=>'comptabilite|accounting|facture|supplier_invoice|don|tax|salaries|loan'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -947,26 +947,27 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("accountancy"); - $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); + $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); $newmenu->add("/accountancy/index.php?leftmenu=accountancy",$langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); // Chart of account if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 22); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=33&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 20); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 30); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 31); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); } if (! empty($conf->tax->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); } if (! empty($conf->expensereport->enabled)) { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); } /* not required yet, already supported by default account if (! empty($conf->loan->enabled)) @@ -977,7 +978,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47); }*/ - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60); // Binding if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); From 7c2b3b8df0cb9b99456ac4010b1d0de913e6176f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 12:55:11 +0200 Subject: [PATCH 089/172] NEW When down payment is entered, discount to reuse into final invoice is automatically created. This save one click into invoice workflow. --- htdocs/compta/facture/card.php | 18 +++--- htdocs/compta/paiement.php | 38 ++++++------ .../compta/paiement/class/paiement.class.php | 60 +++++++++++++++++-- htdocs/langs/en_US/bills.lang | 2 +- 4 files changed, 85 insertions(+), 33 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 70eea532a79..6f5ef85310d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -611,7 +611,9 @@ if (empty($reshook)) { $db->begin(); - // Boucle sur chaque taux de tva + $amount_ht = $amount_tva = $amount_ttc = array(); + + // Loop on each vat rate $i = 0; foreach ($object->lines as $line) { @@ -630,20 +632,19 @@ if (empty($reshook)) $discount->description = '(CREDIT_NOTE)'; elseif ($object->type == Facture::TYPE_DEPOSIT) $discount->description = '(DEPOSIT)'; - elseif ($object->type == Facture::TYPE_STANDARD) + elseif ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) $discount->description = '(EXCESS RECEIVED)'; else { setEventMessages($langs->trans('CantConvertToReducAnInvoiceOfThisType'), null, 'errors'); } - $discount->tva_tx = abs($object->total_ttc); $discount->fk_soc = $object->socid; $discount->fk_facture_source = $object->id; $error = 0; - if ($object->type == Facture::TYPE_STANDARD) { - - // If we're on a standard invoice, we have to get excess received to create it in TTC wuthout VAT + if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) + { + // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT $sql = 'SELECT SUM(pf.amount) as total_paiements FROM llx_c_paiement as c, llx_paiement_facture as pf, llx_paiement as p @@ -663,8 +664,9 @@ if (empty($reshook)) $error++; } - } else { - + } + if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + { foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 96f77e85758..8cd924a0df8 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -221,7 +221,7 @@ if (empty($reshook)) $db->begin(); // Clean parameters amount if payment is for a credit note - if (GETPOST('type') == 2) + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { foreach ($amounts as $key => $value) // How payment is dispatch { @@ -249,7 +249,7 @@ if (empty($reshook)) // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement'); $paiement->num_paiement = GETPOST('num_paiement'); @@ -257,7 +257,7 @@ if (empty($reshook)) if (! $error) { - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -268,7 +268,7 @@ if (empty($reshook)) if (! $error) { $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank')); if ($result < 0) { @@ -281,7 +281,7 @@ if (empty($reshook)) { $db->commit(); - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + // If payment dispatching on more than one invoice, we keep on summary page, otherwise jump on invoice card $invoiceid=0; foreach ($paiement->amounts as $key => $amount) { @@ -309,7 +309,7 @@ if (empty($reshook)) * View */ -llxHeader(); +llxHeader('', $langs->trans("Payment")); $form=new Form($db); @@ -324,8 +324,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $facture->fetch_thirdparty(); $title=''; - if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); + if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) @@ -347,7 +347,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Add realtime total information - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print "\n".''."\n"; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 53035dca96f..03a7759e52c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -255,7 +255,7 @@ class Paiement extends CommonObject { if (! empty($conf->prelevement->enabled)) { - // TODO Check if this payment has a withdraw request + // FIXME Check if this invoice has a withdraw request // if not, $mustwait++; // This will disable automatic close on invoice to allow to process } } @@ -275,11 +275,61 @@ class Paiement extends CommonObject else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); else { - $result=$invoice->set_paid($user,'',''); - if ($result<0) + // If invoice is a down payment, we also convert down payment to discount + if ($invoice->type == Facture::TYPE_DEPOSIT) { - $this->error=$invoice->error; - $error++; + $amount_ht = $amount_tva = $amount_ttc = array(); + + // Loop on each vat rate + $i = 0; + foreach ($invoice->lines as $line) + { + if ($line->total_ht!=0) + { // no need to create discount if amount is null + $amount_ht[$line->tva_tx] += $line->total_ht; + $amount_tva[$line->tva_tx] += $line->total_tva; + $amount_ttc[$line->tva_tx] += $line->total_ttc; + $i ++; + } + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($this->db); + $discount->description = '(DEPOSIT)'; + $discount->fk_soc = $invoice->socid; + $discount->fk_facture_source = $invoice->id; + + foreach ($amount_ht as $tva_tx => $xxx) + { + $discount->amount_ht = abs($amount_ht[$tva_tx]); + $discount->amount_tva = abs($amount_tva[$tva_tx]); + $discount->amount_ttc = abs($amount_ttc[$tva_tx]); + $discount->tva_tx = abs($tva_tx); + + $result = $discount->create($user); + if ($result < 0) + { + $error++; + break; + } + } + + if ($error) + { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + } + } + + // Set invoice to paid + if (! $error) + { + $result=$invoice->set_paid($user,'',''); + if ($result<0) + { + $this->error=$invoice->error; + $error++; + } } } } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 7432f0e2412..189ef5c1fe2 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -447,7 +447,7 @@ CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least ExpectedToPay=Expected payment CantRemoveConciliatedPayment=Can't remove conciliated payment PayedByThisPayment=Paid by this payment -ClosePaidInvoicesAutomatically=Classify "Paid" all standard, situation or replacement invoices entirely paid. +ClosePaidInvoicesAutomatically=Classify "Paid" all standard, down payment or replacement invoices entirely paid. ClosePaidCreditNotesAutomatically=Classify "Paid" all credit notes entirely paid back. ClosePaidContributionsAutomatically=Classify "Paid" all social or fiscal contributions entirely paid. AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be automatically closed to status "Paid". From 58e2b49b1c2c59392e0453f479a9af43b95d6f5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 13:49:06 +0200 Subject: [PATCH 090/172] Clean code --- htdocs/compta/facture/card.php | 13 ------------- htdocs/core/class/commoninvoice.class.php | 3 ++- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6f5ef85310d..7e08bdc7fae 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -873,19 +873,6 @@ if (empty($reshook)) $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); } } - - // Add predefined lines - /* - TODO delete - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - }*/ } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 3e9d56f8f8c..4d9fa7a72af 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -51,7 +51,8 @@ abstract class CommonInvoice extends CommonObject const TYPE_DEPOSIT = 3; /** - * Proforma invoice + * Proforma invoice. + * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! */ const TYPE_PROFORMA = 4; From 072eb740c713bef7210a5474409b274a175f6a22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 13:57:13 +0200 Subject: [PATCH 091/172] Fix php compatibility --- htdocs/product/inventory/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index f7e4cbecb0a..026bd37e743 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -463,7 +463,8 @@ function card_line(&$inventory, &$lines, $mode) if(!empty($TCacheEntrepot[$Inventorydet->fk_warehouse])) $e = $TCacheEntrepot[$Inventorydet->fk_warehouse]; elseif($e->fetch($Inventorydet->fk_warehouse) > 0) $TCacheEntrepot[$e->id] = $e; - $qty = (float)GETPOST('qty_to_add')[$k]; + $qtytoadd = GETPOST('qty_to_add', 'array'); + $qty = (float) $qtytoadd[$k]; $lines[]=array( 'produit' => $product->getNomUrl(1).' - '.$product->label, From 1e3384a842d11f490ca81654e608d629229911bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 14:04:01 +0200 Subject: [PATCH 092/172] Fix travis --- htdocs/core/class/commonobject.class.php | 64 +++++++++- htdocs/core/db/DoliDB.class.php | 117 ------------------ htdocs/product/inventory/card.php | 2 +- htdocs/product/inventory/list.php | 2 +- .../inventory}/listview.class.php | 80 ++++++------ 5 files changed, 104 insertions(+), 161 deletions(-) rename htdocs/{core/class => product/inventory}/listview.class.php (93%) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2526638cee5..5e5c13056e7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4674,7 +4674,26 @@ abstract class CommonObject */ public function createCommon(User $user, $notrigger = false) { + foreach ($this->fields as $k => $v) { + $keys[] = $k; + $values[] = $this->quote($v); + + } + + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.' + ( '.implode( ",", $keys ).' ) + VALUES ( '.implode( ",", $values ).' ) '; + + $res = $this->query($sql); + if($res===false) { + + return false; + } + + // TODO Add triggers + + return true; } @@ -4690,7 +4709,6 @@ abstract class CommonObject { } - /** * Update object into database @@ -4702,10 +4720,36 @@ abstract class CommonObject */ public function updateCommon(User $user, $notrigger = false) { + foreach ($this->fields as $k => $v) { + if (is_array($key)){ + $i=array_search($k, $key); + if ( $i !== false) { + $where[] = $key[$i].'=' . $this->quote( $v ) ; + continue; + } + } else { + if ( $k == $key) { + $where[] = $k.'=' .$this->quote( $v ) ; + continue; + } + } + + $tmp[] = $k.'='.$this->quote($v); + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ; + $res = $this->query( $sql ); + + if($res===false) { + //error + return false; + } + + // TODO Add triggers + + return true; } - /** * Delete object in database * @@ -4718,4 +4762,20 @@ abstract class CommonObject { } + + /** + * Add quote to field value if necessary + * + * @param string|int $value value to protect + * @return string|int + */ + function quote($value) { + + if(is_null($value)) return 'NULL'; + else if(is_numeric($value)) return $value; + else return "'".$this->escape( $value )."'"; + + } + } + diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index fb398270fa6..9fc1739334c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -295,122 +295,5 @@ abstract class DoliDB implements Database { return $this->lastqueryerror; } - /* - * Add quote to field value if necessary - * - * @param string|int $value value to protect - * @return string|int - */ - function quote($value) { - - if(is_null($value)) return 'NULL'; - else if(is_numeric($value)) return $value; - else return "'".$this->escape( $value )."'"; - - } - - /** - * Generate and execute Update SQL commande - * - * @param string $table table to update - * @param array $values array of values to update - * @param int|string|array $key key of value to select row to update - * @return bool|result false or boolean - */ - function update($table,$fields,$key){ - - foreach ($fields as $k => $v) { - - if (is_array($key)){ - $i=array_search($k , $key ); - if ( $i !== false) { - $where[] = $key[$i].'=' . $this->quote( $v ) ; - continue; - } - } else { - if ( $k == $key) { - $where[] = $k.'=' .$this->quote( $v ) ; - continue; - } - } - - $tmp[] = $k.'='.$this->quote($v); - } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ; - $res = $this->query( $sql ); - - if($res===false) { - //error - return false; - } - - return true; - } - - /** - * Generate and execute Insert SQL commande - * - * @param string $table table to update - * @param array $values array of values to update - * @return bool|result false or boolean - */ - function insert($table,$fields){ - - foreach ($fields as $k => $v) { - - $keys[] = $k; - $values[] = $this->quote($v); - - } - - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.' - ( '.implode( ",", $keys ).' ) - VALUES ( '.implode( ",", $values ).' ) '; - - $res = $this->query($sql); - if($res===false) { - - return false; - } - - return true; - } - - /** - * Generate and execute Delete SQL commande - * - * @param string $table table for the delete - * @param array $values array of values to delete - * @param int|string|array $key key of value to select row to update - * @return bool|result false or boolean - */ - function delete($table,$fields,$key){ - foreach ($fields as $k => $v) { - if (is_array($key)){ - $i=array_search($k , $key ); - if ( $i !== false) { - $where[] = $key[$i].'=' . $this->quote( $v ) ; - continue; - } - } else { - if ( $k == $key) { - $where[] = $k.'='.$this->quote( $v ) ; - continue; - } - } - - } - - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.implode(' AND ',$where); - - $res = $this->query( $sql ); - if($res===false) { - return false; - } - - return true; - - } - } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 026bd37e743..dc279cc0929 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -23,7 +23,7 @@ require_once '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/listview.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/inventory/listview.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 36a185d7fd1..57545b07948 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -23,7 +23,7 @@ require_once '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/listview.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/inventory/listview.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/core/class/listview.class.php b/htdocs/product/inventory/listview.class.php similarity index 93% rename from htdocs/core/class/listview.class.php rename to htdocs/product/inventory/listview.class.php index 91dd182fc56..51855629686 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/product/inventory/listview.class.php @@ -103,7 +103,7 @@ class Listview /** * @param string $key field name - * @param array $TParam array of configuration + * @param string $TParam array of configuration * @return array */ private function getSearchKey($key, &$TParam) @@ -149,7 +149,7 @@ class Listview /** - * @param array $TSQLMore contain some additional sql instructions + * @param string $TSQLMore contain some additional sql instructions * @param string $value date with read format * @param string $sKey field name */ @@ -181,9 +181,9 @@ class Listview /** - * @param array $TSQLMore contain some additional sql instructions + * @param string $TSQLMore contain some additional sql instructions * @param string $value value to filter - * @param array $TParam array of configuration + * @param string $TParam array of configuration * @param string $sKey field name * @param string $key reference of sKey to find value into TParam * @return bool @@ -222,7 +222,7 @@ class Listview /** * @param string $sql standard select sql - * @param array $TParam array of configuration + * @param string $TParam array of configuration * @return string */ private function search($sql, &$TParam) @@ -289,7 +289,7 @@ class Listview /** * @param string $sql standard select sql - * @param array $TParam array of configuration + * @param string $TParam array of configuration * @return string */ public function render($sql, $TParam=array()) @@ -321,8 +321,8 @@ class Listview } /** - * @param array $THeader the configuration of header - * @param array $TParam array of configuration + * @param string $THeader the configuration of header + * @param string $TParam array of configuration * @return array */ private function setSearch(&$THeader, &$TParam) @@ -427,8 +427,8 @@ class Listview /** * Function to analyse and calculate the total from a column * - * @param $TField - * @param $TParam + * @param string $TField TField + * @param string $TParam TParam * @return array */ private function get_total(&$TField, &$TParam) @@ -495,9 +495,9 @@ class Listview */ /** - * @param $TParam - * @param $TField - * @param $THeader + * @param string $TParam TParam + * @param string $TField TField + * @param string $THeader THeader * @return array */ private function setExport(&$TParam, $TField, $THeader) @@ -535,8 +535,8 @@ class Listview } /** - * @param $TField - * @param $TTotalGroup + * @param string $TField TField + * @param string $TTotalGroup TTotalGroup * @return array */ private function addTotalGroup($TField, $TTotalGroup) @@ -594,11 +594,11 @@ class Listview } /** - * @param $THeader - * @param $TField - * @param $TTotal - * @param $TTotalGroup - * @param $TParam + * @param string $THeader THeader + * @param string $TField TField + * @param string $TTotal TTotal + * @param string $TTotalGroup TTotalGroup + * @param string $TParam TParam * @return string */ private function renderList(&$THeader, &$TField, &$TTotal, &$TTotalGroup, &$TParam) @@ -723,9 +723,9 @@ class Listview } /** - * @param $db - * @param $TField - * @param array $TParam + * @param string $db Db + * @param string $TField TField + * @param string $TParam TParam */ public function renderArray(&$db, $TField, $TParam=array()) { @@ -744,9 +744,9 @@ class Listview /** - * @param $THeader - * @param $TField - * @param $TParam + * @param string $THeader THeader + * @param string $TField TField + * @param string $TParam TParam * @return bool */ private function parse_array(&$THeader, &$TField, &$TParam) @@ -853,8 +853,8 @@ class Listview } /** - * @param $TParam - * @param $line_number + * @param string $TParam TParam + * @param string $line_number aaa * @return bool */ private function in_view(&$TParam, $line_number) @@ -874,9 +874,9 @@ class Listview } /** - * @param $TField - * @param $TParam - * @param $currentLine + * @param string $TField TField + * @param string $TParam TParam + * @param string $currentLine aaa */ private function set_line(&$TField, &$TParam, $currentLine) { @@ -910,7 +910,7 @@ class Listview if(isset($TParam['eval'][$field]) && in_array($field,array_keys($row))) { - $strToEval = 'return '.strtr( $TParam['eval'][$field] , array_merge( $trans, array('@val@'=>$row[$field]) )).';'; + $strToEval = 'return '.strtr( $TParam['eval'][$field], array_merge( $trans, array('@val@'=>$row[$field]) )).';'; $row[$field] = eval($strToEval); } @@ -932,7 +932,7 @@ class Listview if($TParam['type'][$field]=='hour') { $row[$field] = date('H:i', strtotime($row[$field])); } if($TParam['type'][$field]=='money') { $row[$field] = '
    '.price($row[$field],0,'',1,-1,2).'
    '; } if($TParam['type'][$field]=='number') { $row[$field] = '
    '.price($row[$field]).'
    '; } - if($TParam['type'][$field]=='integer') { $row[$field] = '
    '.(int)$row[$field].'
    '; } + if($TParam['type'][$field]=='integer') { $row[$field] = '
    '.((int) $row[$field]).'
    '; } } if(isset($TParam['link'][$field])) @@ -945,7 +945,7 @@ class Listview { if(isset($TParam['translate'][$field][''])) unset($TParam['translate'][$field]['']); - $row[$field] = strtr( $row[$field] , $TParam['translate'][$field]); + $row[$field] = strtr( $row[$field], $TParam['translate'][$field]); } } } @@ -986,8 +986,8 @@ class Listview } /** - * @param $sql - * @param $TParam + * @param string $sql sql + * @param string $TParam TParam * @return string */ private function limitSQL($sql, &$TParam) @@ -1001,10 +1001,10 @@ class Listview } /** - * @param $THeader - * @param $TField - * @param $TParam - * @param $sql + * @param string $THeader THeader + * @param string $TField TField + * @param string $TParam TParam + * @param string $sql sql */ private function parse_sql(&$THeader, &$TField, &$TParam, $sql) { From e11254a9bf8cc5f23974db3b91b1065ca2610a65 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 30 Apr 2017 15:04:51 +0200 Subject: [PATCH 093/172] Add option on accounting account getNomUrl --- .../class/accountingaccount.class.php | 55 ++++++++++++++----- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 4174ee7809f..dfb29be6323 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -364,28 +364,55 @@ class AccountingAccount extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $withlabel 0=No label, 1=Include label of account + * @param string $moretitle Add more text to title tooltip + * @param int $notooltip 1=Disable tooltip + * @return string String with URL */ - function getNomUrl($withpicto = 0) { - global $langs; + function getNomUrl($withpicto = 0, $withlabel = 0, $moretitle='',$notooltip=0) + { + global $langs, $conf, $user; + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $link = ''; - $linkend = ''; + $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; $picto = 'billr'; + $label=''; - $label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label; + $label = '' . $langs->trans("ShowAccountingAccount") . ''; + if (! empty($this->account_number)) + $label .= '
    '.$langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); + if (! empty($this->label)) + $label .= '
    '.$langs->trans('Label') . ': ' . $this->label; + if ($moretitle) $label.=' - '.$moretitle; - if ($withpicto) - $result .= ($link . img_object($label, $picto) . $linkend); - if ($withpicto && $withpicto != 2) - $result .= ' '; - if ($withpicto != 2) - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $result .= $link . length_accountg($this->account_number) . ' - ' . $this->label . $linkend; + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowAccoutingAccount"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip"'; + } + + $linkstart=''; + $linkend=''; + + $label_link = length_accountg($this->account_number); + if ($withlabel) $label_link .= ' - ' . $this->label; + + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index bd1e41c5464..f9162c5ca21 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -59,6 +59,7 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account +ShowAccoutingAccount=Show accounting account AccountAccountingSuggest=Accounting account suggested MenuDefaultAccounts=Default accounts MenuVatAccounts=Vat accounts From 1dd462d94783bc972ba8fc08daf80db5b49dc5dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Apr 2017 23:39:35 +0200 Subject: [PATCH 094/172] Fix disable notification on smartphone --- htdocs/main.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6a92e0f4eed..ab92df9ca12 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1271,9 +1271,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { $enablebrowsernotif=false; if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_NOTIFICATION)) $enablebrowsernotif=true; + if ($conf->browser->layout == 'phone') $enablebrowsernotif=false; if ($enablebrowsernotif) { - print ''."\n"; + print ''."\n"; print ''."\n"; } } From 6afd0d642a7bc6a70278f93b35273364609e64a3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 May 2017 08:16:09 +0200 Subject: [PATCH 095/172] Finish to move accountancy journals list to page like dictionnary --- htdocs/accountancy/admin/journals_card.php | 296 ------- htdocs/accountancy/admin/journals_list.php | 808 +++++++++++++++--- .../class/accountingjournal.class.php | 260 ------ htdocs/core/menus/init_menu_auguria.sql | 17 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/install/mysql/data/llx_accounting.sql | 8 +- .../mysql/tables/llx_accounting_journal.sql | 2 +- htdocs/langs/en_US/accountancy.lang | 10 +- htdocs/langs/en_US/admin.lang | 1 + 9 files changed, 720 insertions(+), 684 deletions(-) delete mode 100644 htdocs/accountancy/admin/journals_card.php diff --git a/htdocs/accountancy/admin/journals_card.php b/htdocs/accountancy/admin/journals_card.php deleted file mode 100644 index aae3f8b2cb1..00000000000 --- a/htdocs/accountancy/admin/journals_card.php +++ /dev/null @@ -1,296 +0,0 @@ - - * - * 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/accountancy/admin/journals_card.php - * \ingroup Advanced accountancy - * \brief Page to show an accounting journal - */ -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; - -$langs->load("admin"); -$langs->load("compta"); -$langs->load("accountancy"); - -// Security check -if ($user->societe_id > 0) - accessforbidden(); -if (empty($user->rights->accounting->fiscalyear)) - accessforbidden(); - -$error = 0; - -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$id = GETPOST('id', 'int'); - -// List of status -static $tmptype2label = array ( - '0' => 'AccountingJournalTypeVariousOperation', - '1' => 'AccountingJournalTypeSale', - '2' => 'AccountingJournalTypePurchase', - '3' => 'AccountingJournalTypeBank', - '9' => 'AccountingJournalTypeHasNew' -); -$type2label = array ( - '' -); -foreach ( $tmptype2label as $key => $val ) - $type2label[$key] = $langs->trans($val); - -$object = new AccountingJournal($db); - -/* - * Actions - */ - -if ($action == 'confirm_delete' && $confirm == "yes") { - $result = $object->delete($id); - if ($result >= 0) { - header("Location: journals_list.php"); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -else if ($action == 'add') { - if (! GETPOST('cancel', 'alpha')) { - $error = 0; - - $object->code = GETPOST('code', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->nature = GETPOST('nature', 'int'); - - if (empty($object->code)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Code")), null, 'errors'); - $error ++; - } - if (empty($object->label)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $error ++; - } - - if (! $error) { - $db->begin(); - - $id = $object->create($user); - - if ($id > 0) { - $db->commit(); - - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit(); - } else { - $db->rollback(); - - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'create'; - } - } else { - $action = 'create'; - } - } else { - header("Location: journals_list.php"); - exit(); - } -} - -// Update record -else if ($action == 'update') { - if (! GETPOST('cancel', 'alpha')) { - $result = $object->fetch($id); - - $object->code = GETPOST('code', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->nature = GETPOST('nature', 'int'); - - if (empty($object->code)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Code")), null, 'errors'); - $error ++; - } - if (empty($object->label)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $error ++; - } - - $result = $object->update($user); - - if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit(); - } -} - - - -/* - * View - */ - -$title = $langs->trans("Journal") . " - " . $langs->trans("Card"); -$helpurl = ""; -llxHeader("",$title,$helpurl); - -$form = new Form($db); - -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("NewAccountingJournal")); - - print '
    '; - print ''; - print ''; - - dol_fiche_head(); - - print ''; - - // Code - print ''; - - - // Label - print ''; - - // Nature - print ''; - print ''; - print ''; - - print '
    ' . $langs->trans("Code") . '
    ' . $langs->trans("Label") . '
    ' . $langs->trans("Type") . ''; - print $form->selectarray('nature', $type2label, GETPOST('nature')); - print '
    '; - - dol_fiche_end(); - - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; - - print '
    '; -} else if ($id) { - $result = $object->fetch($id); - if ($result > 0) { - $head = accounting_journal_prepare_head($object); - - if ($action == 'edit') { - dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron'); - - print '
    ' . "\n"; - print ''; - print ''; - print ''; - - print ''; - - // Code - print ""; - print ''; - - // Label - print ''; - - // Nature - print ''; - - print '
    ' . $langs->trans("Code") . ''; - print ''; - print '
    ' . $langs->trans("Label") . ''; - print ''; - print '
    ' . $langs->trans("Type") . ''; - print $form->selectarray('nature', $type2label, $object->nature); - print '
    '; - - dol_fiche_end(); - - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; - - print '
    '; - - dol_fiche_end(); - } else { - /* - * Confirm delete - */ - if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); - } - - dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron'); - - print ''; - - $linkback = '' . $langs->trans("BackToList") . ''; - - // Ref - print ''; - - // Label - print '"; - - // Nature - print ''; - - print "
    ' . $langs->trans("Code") . ''; - print $object->code; - print ''; - print $linkback; - print '
    '; - print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); - print ''; - print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); - print "
    ' . $langs->trans("Type") . '' . $object->getLibType(0) . '
    "; - - dol_fiche_end(); - - if (! empty($user->rights->accounting->chartofaccount)) - { - /* - * Barre d'actions - */ - print '
    '; - - print '' . $langs->trans('Modify') . ''; - - print '' . $langs->trans('Delete') . ''; - - print '
    '; - } - } - } else { - dol_print_error($db); - } -} - -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index f7ba79457a8..be532c7c25f 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -22,147 +22,737 @@ * \brief Setup page to configure journals */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; - -$action = GETPOST('action'); - -// Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield="j.rowid"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("admin"); $langs->load("compta"); $langs->load("accountancy"); -// Security check -if ($user->societe_id > 0) +$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; +$confirm=GETPOST('confirm','alpha'); +$id=GETPOST('id','int'); +$rowid=GETPOST('rowid','alpha'); + +// Security access +if (! empty($user->rights->accountancy->chartofaccount)) +{ accessforbidden(); -if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year. - accessforbidden(); - +} + +$acts[0] = "activate"; +$acts[1] = "disable"; +$actl[0] = img_picto($langs->trans("Disabled"),'switch_off'); +$actl[1] = img_picto($langs->trans("Activated"),'switch_on'); + +$listoffset=GETPOST('listoffset'); +$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; +$active = 1; + +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0 ; } +$offset = $listlimit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + $error = 0; -// List of status -/* -static $tmptype2label = array ( - '0' => 'AccountingJournalTypeVariousOperation', - '1' => 'AccountingJournalTypeSale', - '2' => 'AccountingJournalTypePurchase', - '3' => 'AccountingJournalTypeBank', - '9' => 'AccountingJournalTypeHasNew' -); -$type2label = array ( - '' -); -foreach ( $tmptype2label as $key => $val ) - $type2label[$key] = $langs->trans($val); -*/ +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('admin')); -$errors = array (); +// This page is a generic page to edit dictionaries +// Put here declaration of dictionaries properties -$object = new AccountingJournal($db); +// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. +$taborder=array(35); +// Name of SQL tables of dictionaries +$tabname=array(); +$tabname[35]= MAIN_DB_PREFIX."accounting_journal"; + +// Dictionary labels +$tablib=array(); +$tablib[35]= "DictionaryAccountancyJournal"; + +// Requests to extract data +$tabsql=array(); +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; + +// Criteria to sort dictionaries +$tabsqlsort=array(); +$tabsqlsort[35]="code ASC"; + +// Nom des champs en resultat de select pour affichage du dictionnaire +$tabfield=array(); +$tabfield[35]= "code,label,nature"; + +// Nom des champs d'edition pour modification d'un enregistrement +$tabfieldvalue=array(); +$tabfieldvalue[35]= "code,label,nature"; + +// Nom des champs dans la table pour insertion d'un enregistrement +$tabfieldinsert=array(); +$tabfieldinsert[35]= "code,label,nature"; + +// Nom du rowid si le champ n'est pas de type autoincrement +// Example: "" if id field is "rowid" and has autoincrement on +// "nameoffield" if id field is not "rowid" or has not autoincrement on +$tabrowid=array(); +$tabrowid[35]= ""; + +// Condition to show dictionary in setup page +$tabcond=array(); +$tabcond[35]= ! empty($conf->accounting->enabled); + +// List of help for fields +$tabhelp=array(); +$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode")); + +// List of check for fields (NOT USED YET) +$tabfieldcheck=array(); +$tabfieldcheck[35] = array(); + +// Complete all arrays with entries found into modules +complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); + + +// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") +$elementList = array(); + $sourceList = array( + '1' => $langs->trans('AccountingJournalType0'), + '2' => $langs->trans('AccountingJournalType1'), + '3' => $langs->trans('AccountingJournalType2'), + '4' => $langs->trans('AccountingJournalType3'), + '9' => $langs->trans('AccountingJournalType9') + ); /* * Actions */ +if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) +{ + $search_country_id = ''; +} +// Actions add or modify an entry into a dictionary +if (GETPOST('actionadd') || GETPOST('actionmodify')) +{ + $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); + $listfieldinsert=explode(',',$tabfieldinsert[$id]); + $listfieldmodify=explode(',',$tabfieldinsert[$id]); + $listfieldvalue=explode(',',$tabfieldvalue[$id]); + + // Check that all fields are filled + $ok=1; + foreach ($listfield as $f => $value) + { + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'nature') $fieldnamekey = 'Nature'; + } + // Other checks + if (isset($_POST["code"])) + { + if ($_POST["code"]=='0') + { + $ok=0; + setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); + } + /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base + { + $ok = 0; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
    '; + }*/ + } + + // Clean some parameters + if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null + if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null + if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null + + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $newid=0; + $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $newid=($obj->newid + 1); + + } else { + dol_print_error($db); + } + } + + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $tabrowid[$id].","; + $sql.= $tabfieldinsert[$id]; + $sql.=",active)"; + $sql.= " VALUES("; + + // List of values + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $newid.","; + $i=0; + foreach ($listfieldinsert as $f => $value) + { + if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') { + $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); + } + else if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql.=",1)"; + + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST=array('id'=>$id); // Clean $_POST array, we keep only + } + else + { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } + else { + dol_print_error($db); + } + } + } + + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify')) + { + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) + { + $sql.= $tabrowid[$id]."="; + $sql.= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') { + $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); + } + else if ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + $sql.= $field."="; + if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (! $resql) + { + setEventMessages($db->error(), null, 'errors'); + } + } + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition +} + +if (GETPOST('actioncancel')) +{ + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition +} + +if ($action == 'confirm_delete' && $confirm == 'yes') // delete +{ + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; + + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (! $result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } + else + { + dol_print_error($db); + } + } +} + +// activate +if ($action == $acts[0]) +{ + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($_GET["code"]) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } +} + +// disable +if ($action == $acts[1]) +{ + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($_GET["code"]) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } +} /* * View */ -$title = $langs->trans('AccountingJournals'); -$helpurl = ""; -llxHeader('', $title, $helpurl); -$max = 100; $form = new Form($db); +$formadmin=new FormAdmin($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); +llxHeader(); -$head = admin_accounting_prepare_head(null); - -dol_fiche_head($head, 'journal', $langs->trans("Configuration"), -1, 'cron'); - -$sql = "SELECT j.rowid, j.code, j.label, j.nature, j.active"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_journal as j"; -// $sql .= " WHERE j.entity = " . $conf->entity; -$sql.=$db->order($sortfield,$sortorder); - -// Count total nb of records -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +$titre=$langs->trans("DictionarySetup"); +$linkback=''; +if ($id) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $titre.=' - '.$langs->trans($tablib[$id]); + $titlepicto='title_accountancy'; } -$sql.= $db->plimit($limit+1, $offset); +print load_fiche_titre($titre,$linkback,$titlepicto); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); - - $i = 0; - - // $title = $langs->trans('AccountingJournals'); - // print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 1); - - // Load attribute_label - print ''; - print ''; - // print ''; - print ''; - print ''; - print ''; - print ''; - - if ($num) { - $accountingjournalstatic = new AccountingJournal($db); - - while ( $i < $num && $i < $max ) { - $obj = $db->fetch_object($result); - $accountingjournalstatic->id = $obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - $i ++; - } - } else { - print ''; - } - print '
    ' . $langs->trans("Ref") . '' . $langs->trans("Code") . '' . $langs->trans("Label") . '' . $langs->trans("Nature") . '
    ' . img_object($langs->trans("ShowJournal"), "technic") . ' ' . $obj->code . '' . $obj->label . '' . $accountingjournalstatic->LibType($obj->nature, 0) . '
    ' . $langs->trans("None") . '
    '; -} else { - dol_print_error($db); -} - -dol_fiche_end(); - -// Buttons -print '
    '; -if (! empty($user->rights->accounting->chartofaccount)) +if (empty($id)) { - print '' . $langs->trans("NewAccountingJournal") . ''; + print $langs->trans("DictionaryDesc"); + print " ".$langs->trans("OnlyActiveElementsAreShown")."
    \n"; } -else +print "
    \n"; + + +// Confirmation de la suppression de la ligne +if ($action == 'delete') { - print '' . $langs->trans("NewAccountingJournal") . ''; + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } -print '
    '; +//var_dump($elementList); + +/* + * Show a dictionary + */ +if ($id) +{ + // Complete requete recherche valeurs avec critere de tri + $sql=$tabsql[$id]; + + if ($search_country_id > 0) + { + if (preg_match('/ WHERE /',$sql)) $sql.= " AND "; + else $sql.=" WHERE "; + $sql.= " c.rowid = ".$search_country_id; + } + + if ($sortfield) + { + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.= " ORDER BY ".$sortfield; + if ($sortorder) + { + $sql.=" ".strtoupper($sortorder); + } + $sql.=", "; + // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value + $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); + $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); + } + else { + $sql.=" ORDER BY "; + } + $sql.=$tabsqlsort[$id]; + $sql.=$db->plimit($listlimit+1,$offset); + //print $sql; + + $fieldlist=explode(',',$tabfield[$id]); + + print '
    '; + print ''; + print ''; + + print ''; + + // Form to add a new line + if ($tabname[$id]) + { + $alabelisused=0; + $var=false; + + $fieldlist=explode(',',$tabfield[$id]); + + // Line for title + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow=$langs->trans($valuetoshow); // try to translate + $align="left"; + if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') + { + $valuetoshow=$langs->trans("Label"); + } + if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } + + if ($valuetoshow != '') + { + print ''; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + + if ($id == 4) print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Line to enter new values + print ""; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd')) + { + foreach ($fieldlist as $key=>$val) + { + if (GETPOST($val) != '') + $obj->$val=GETPOST($val); + } + } + + $tmpaction = 'create'; + $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error=$hookmanager->error; $errors=$hookmanager->errors; + + if (empty($reshook)) + { + fieldList($fieldlist,$obj,$tabname[$id],'add'); + } + + print ''; + print ""; + + $colspan=count($fieldlist)+3; + + if (! empty($alabelisused)) // If there is one label among fields, we show legend of * + { + print ''; + } + print ''; // Keep   to have a line with enough height + } + + + + // List of available record in database + dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $var=true; + + $param = '&id='.$id; + if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; + if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; + if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); + + // There is several pages + if ($num > $listlimit) + { + print ''; + } + + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $showfield=1; // By defaut + $align="left"; + $sortable=1; + $valuetoshow=''; + /* + $tmparray=getLabelOfField($fieldlist[$field]); + $showfield=$tmp['showfield']; + $valuetoshow=$tmp['valuetoshow']; + $align=$tmp['align']; + $sortable=$tmp['sortable']; + */ + $valuetoshow=ucfirst($fieldlist[$field]); // By defaut + $valuetoshow=$langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } + if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } + + // Affiche nom du champ + if ($showfield) + { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); + } + } + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print ''; + + // Title line with search boxes + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); + //print_r($obj); + print ''; + if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + { + $tmpaction='edit'; + $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error=$hookmanager->error; $errors=$hookmanager->errors; + + // Show fields + if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); + + print ''; + print ''; + print ''; + } + else + { + $tmpaction = 'view'; + $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + + $error=$hookmanager->error; $errors=$hookmanager->errors; + + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + + $showfield=1; + $align="left"; + $valuetoshow=$obj->{$fieldlist[$field]}; + if ($valuetoshow=='all') { + $valuetoshow=$langs->trans('All'); + } + else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { + $langs->load("accountancy"); + $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); + $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]}); + } + + $class='tddict'; + // Show value for field + if ($showfield) print ''; + } + } + + // Can an entry be erased or disabled ? + $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default + if (isset($obj->code) && $id != 10) + { + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $canbedisabled = 0; } + else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; } + else if ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } + } + + if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } + if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } + $canbemodified=$iserasable; + if ($obj->code == 'RECEP') $canbemodified=1; + + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); + if ($param) $url .= '&'.$param; + $url.='&'; + + // Active + print '"; + + // Modify link + if ($canbemodified) print ''; + else print ''; + + // Delete link + if ($iserasable) + { + print ''; + } + else print ''; + + print ''; + print "\n"; + } + $i++; + } + } + } + else { + dol_print_error($db); + } + + print '
    '; + if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; + else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); + else print $valuetoshow; + print ''; + print ''; + print '
    '; + print ''; + print '
    * '.$langs->trans("LabelUsedByDefault").'.
     
    '; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
    '; + if ($filterfound) + { + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + } + print '
    '; + print ''; + print ''; + print ''; + print '
    '; + print ''; + print '
    '.$valuetoshow.''; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else + { + if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); + else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated"); + else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); + else print $langs->trans("AlwaysActive"); + } + print "'.img_edit().' '; + if ($user->admin) print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionnary can be edited by other profile than admin + print ' 
    '; + + print '
    '; +} + +print '
    '; + llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); + + +/** + * Show fields in insert/edit mode + * + * @param array $fieldlist Array of fields + * @param Object $obj If we show a particular record, obj is filled with record fields + * @param string $tabname Name of SQL table + * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered + * @return void + */ +function fieldList($fieldlist, $obj='', $tabname='', $context='') +{ + global $conf,$langs,$db; + global $form, $mysoc; + global $region_id; + global $elementList,$sourceList,$localtax_typeList; + global $bc; + + $formadmin = new FormAdmin($db); + $formcompany = new FormCompany($db); + + foreach ($fieldlist as $field => $value) + { + if ($fieldlist[$field] == 'nature') + { + print '
    '; + print $form->selectarray('nature', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print ''; + $size=''; $class=''; + if ($fieldlist[$field]=='code') $class='maxwidth100'; + if ($fieldlist[$field]=='label') $class='quatrevingtpercent'; + if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; + print ''; + print ' 
    ".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.yn($extrafields->attribute_alwayseditable[$key])."'.yn($extrafields->attribute_hidden[$key])."'.img_edit().''; + print "  ".img_delete()."
    ".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.yn($extrafields->attribute_alwayseditable[$key])."'.yn($extrafields->attribute_hidden[$key])."'.img_edit().''; - print "  ".img_delete()."
    '; + print $langs->trans("None"); + print '
    "; From 6e1f82519020ac0a38532438df32a8481eb63f1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 May 2017 13:01:05 +0200 Subject: [PATCH 097/172] Look and feel v6 --- htdocs/admin/clicktodial.php | 3 ++- htdocs/core/lib/ajax.lib.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 060c910753a..86b94d8ecf0 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -91,7 +91,8 @@ print ''; print ''; print $langs->trans("DefaultLink").''; -print 'global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS?' disabled="disabled"':'').' value="'.$conf->global->CLICKTODIAL_URL.'">
    '; +print 'global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS?' disabled="disabled"':'').' value="'.$conf->global->CLICKTODIAL_URL.'">
    '; +print ajax_autoselect('CLICKTODIAL_URL'); print '
    '; print $langs->trans("ClickToDialUrlDesc").'
    '; print $langs->trans("Example").':
    http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__'; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 942c17f5df9..49218ddf141 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -349,7 +349,7 @@ function ajax_dialog($title,$message,$w=350,$h=150) /** - * Make a input box content all selected + * Make content of an input box selected when we click into input field. * * @param string $htmlname Id of html object * @param int $addlink Add a link to after diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 02ff5740986..35037387c1f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1501,7 +1501,7 @@ AGENDA_NOTIFICATION=Enable event notification on user browsers when event date i AGENDA_NOTIFICATION_SOUND=Enable sound notification ##### Clicktodial ##### ClickToDialSetup=Click To Dial module setup -ClickToDialUrlDesc=Url called when a click on phone picto is done. In URL, you can use tags
    __PHONETO__ that will be replaced with the phone number of person to call
    __PHONEFROM__ that will be replaced with phone number of calling person (yours)
    __LOGIN__ that will be replaced with your clicktodial login (defined on your user card)
    __PASS__ that will be replaced with your clicktodial password (defined on your user card). +ClickToDialUrlDesc=Url called when a click on phone picto is done. In URL, you can use tags
    __PHONETO__ that will be replaced with the phone number of person to call
    __PHONEFROM__ that will be replaced with phone number of calling person (yours)
    __LOGIN__ that will be replaced with clicktodial login (defined on user card)
    __PASS__ that will be replaced with clicktodial password (defined on user card). ClickToDialDesc=This module allows to make phone numbers clickable. A click on this icon will call make your phone to call the phone number. This can be used to call a call center system from Dolibarr that can call the phone number on a SIP system for example. ClickToDialUseTelLink=Use just a link "tel:" on phone numbers ClickToDialUseTelLinkDesc=Use this method if your users have a softphone or a software interface installed on same computer than the browser, and called when you click on a link in your browser that start with "tel:". If you need a full server solution (no need of local software installation), you must set this to "No" and fill next field. From 8730add15f70eab2a1f458f047f4f2df7c797358 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 May 2017 16:01:39 +0200 Subject: [PATCH 098/172] Better message for api key return --- build/debian/README.howto | 29 +++++++++++++++++++++------- htdocs/api/class/api_login.class.php | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 705899d47c4..399c4f07a1f 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -385,13 +385,14 @@ http://packages.qa.debian.org * Package will be into release when test will be moved as stable. -##### Send an unblock request + +##### Send an unblock request to make a full update of a stable package Use this to move from unstable to testing. reportbug -B debian --smtphost=smtp.gmail.com:587 --smtpuser=xxxx --smtppasswd=yyyy --tls Choose package "release.debian.org" -Then "unblock" +Then usertag "unblock" Then name of package "dolibarr" Fill message, for example: "Please unblock package dolibarr @@ -400,12 +401,11 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. After discussion with ..., it appears that security holes are enough to request this unblock request." - -Use this to request an update of a stable package +Use this to request an full update of a stable package reportbug -B debian --smtphost=smtp.gmail.com:587 --smtpuser=xxxx --smtppasswd=yyyy --tls Choose package "release.debian.org" -Then "unblock" +Then usertag "unblock" Then name of package "dolibarr" Fill message, for example: " @@ -417,11 +417,26 @@ Pro are: - It fixes also stability bugs - Patches were already tested because deployed and used by several thousands of users. - It is easier for package maintener to include this official set of fixes than applying one patch after one patch for each debian report or backported each patch into a dedicated version. -- Debian maintenance version matches with official project maintenance version (better when all fixes are not related to the way the software is packaged) +- Debian maintenance version is inline with official project maintenance version (better when all fixes are not related to the way the software is packaged) Cons are: -- The patch include more than the only one security reported fxes +- The patch include more than the only one security reported fixes So I just need to know if it's ok to push such a version 3.5.7 (fixes for 3.5.* branch) instead of only one fix for only the few (the only) reported debian bugs, since it provides more stability and is for me a more secured process. " +##### Send an request to ask a simple fix of a stable package + +Use this to ask to apply patches on a stable version. + +reportbug -B debian --smtphost=smtp.gmail.com:587 --smtpuser=xxxx --smtppasswd=yyyy --tls +Choose package "release.debian.org" +Then usertag "jessie-pu" +Then name of package "dolibarr" +Fill message, for example: +"Please unblock package dolibarr +A security error CVE-2015-3935 was reported and is fixed into package 3.5.7. +Note that package 3.5.7 contains not only fixed for bugs reported to debian. It includes other fixes, but they are all related to stability or security, +so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. +After discussion with ..., it appears that security holes are enough to request this unblock request." + diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 704ec1b6874..76a9befebc9 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -102,7 +102,7 @@ class Login 'success' => array( 'code' => 200, 'token' => $token, - 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call)') + 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); } From 94b69844f2a57a021ac311b78a6285f1724c6081 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 May 2017 20:39:46 +0200 Subject: [PATCH 099/172] Add option no url --- htdocs/accountancy/class/accountingaccount.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index dfb29be6323..8bf7dfe0c44 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -366,11 +366,12 @@ class AccountingAccount extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withlabel 0=No label, 1=Include label of account + * @param int $nourl 1=Disable url * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $moretitle='',$notooltip=0) + function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0) { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -407,6 +408,13 @@ class AccountingAccount extends CommonObject $linkstart.=$linkclose.'>'; $linkend=''; + if ($nourl) + { + $linkstart = ''; + $linkclose = ''; + $linkend = ''; + } + $label_link = length_accountg($this->account_number); if ($withlabel) $label_link .= ' - ' . $this->label; From 102deccba74cf8846e4568f9dd0fea8946c8b42e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 May 2017 21:06:31 +0200 Subject: [PATCH 100/172] Use getnomUrl on bank accountancy number --- htdocs/compta/bank/card.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index df6e6b1c8c8..6576b12d494 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1,11 +1,11 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2014-2016 Alexandre Spangaro - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Marcos García + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2014-2017 Alexandre Spangaro + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; $langs->load("banks"); $langs->load("bills"); @@ -664,7 +665,10 @@ else print ''.$langs->trans("AccountancyCode").''; print ''; if (! empty($conf->accounting->enabled)) { - print length_accountg($object->account_number).''; + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->account_number); + + print $accountingaccount->getNomUrl(1,1,1,'',1); } else { print $object->account_number; } @@ -683,13 +687,11 @@ else print ''; - print '
    '; print '
    '; print '
    '; print '
    '; - print ''; // Categories @@ -703,8 +705,7 @@ else print ''; print '
    '.dol_htmlentitiesbr($object->comment).'
    '; - - + if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) { print '
    '; From e1e2481e3791b5bf2b87dc467d52e2369f46b149 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 May 2017 21:09:09 +0200 Subject: [PATCH 101/172] Remove picto --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 6576b12d494..802c37a6946 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -668,7 +668,7 @@ else $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('',$object->account_number); - print $accountingaccount->getNomUrl(1,1,1,'',1); + print $accountingaccount->getNomUrl(0,1,1,'',1); } else { print $object->account_number; } From fa4bb4e80a5e98c1312b0f319261fee07043a696 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 May 2017 21:12:52 +0200 Subject: [PATCH 102/172] Remove accounting.lib.php --- htdocs/compta/bank/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 802c37a6946..5b3bb3a58fe 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; From 9641a240ead9a444c6555b3f807736980315ac5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 11:27:35 +0200 Subject: [PATCH 103/172] Complete vat dictionnary --- htdocs/admin/dict.php | 19 ++++++++++--------- htdocs/install/mysql/data/llx_c_tva.sql | 6 ++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d4aa0ce6989..c2730e6c034 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -918,10 +918,19 @@ if (empty($id)) print "
    \n"; +$param = '&id='.$id; +if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; +if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); +$paramwithsearch = $param; +if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; +if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; +if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); + + // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.urlencode($_GET["code"]).'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.$rowid.'&code='.urlencode($_GET["code"]).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -1134,14 +1143,6 @@ if ($id) $num = $db->num_rows($resql); $i = 0; - $param = '&id='.$id; - if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; - if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; - if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; - if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - // There is several pages if ($num > $listlimit) { diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 81c72eccb8f..34842ed324e 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -96,12 +96,14 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (80 -- FRANCE (id country=1) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 12, 1, '8.5','0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 13, 1, '8.5','1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values ( 12, 1, '8.5', '8.5', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT reduced rate (France hors DOM-TOM)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 16, 1, '2.1','0','VAT super-reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 17, 1, '10','0','VAT reduced rate',1); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); -- GERMANY (id country=5) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 51, 5, '19.0','0','allgemeine Ust.',1); From 31d99bbfe6c0956c4b9633e2f4127808602366ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 11:28:40 +0200 Subject: [PATCH 104/172] Complete event tracked automatically --- ...terface_50_modAgenda_ActionsAuto.class.php | 73 +-- htdocs/expensereport/card.php | 478 ++++++++++-------- .../mysql/data/llx_c_action_trigger.sql | 4 + .../install/mysql/migration/5.0.0-6.0.0.sql | 22 + htdocs/install/mysql/tables/llx_holiday.sql | 4 +- 5 files changed, 304 insertions(+), 277 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 84517e36c08..bce6d69b2fa 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -87,7 +87,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name); if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; $object->socid=$object->id; @@ -100,7 +99,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; @@ -114,7 +112,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -127,7 +124,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -142,7 +138,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -157,7 +152,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -170,7 +164,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -183,7 +176,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -195,7 +187,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -208,7 +199,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -221,7 +211,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -234,7 +223,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -249,7 +237,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -264,7 +251,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -277,7 +263,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -292,7 +277,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -308,7 +292,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -321,7 +304,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -334,7 +316,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; $object->fk_element=0; @@ -349,7 +330,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; $object->fk_element=0; @@ -364,7 +344,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; $object->fk_element=0; @@ -379,7 +358,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } @@ -392,7 +371,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -405,7 +383,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -418,7 +395,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; $object->fk_element=0; @@ -435,7 +411,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -452,7 +427,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -467,7 +441,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -480,7 +453,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -493,7 +465,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -506,7 +477,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -519,7 +489,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -532,7 +501,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -548,7 +516,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -566,7 +533,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } $object->sendtoid=0; @@ -580,7 +546,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -593,7 +558,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -609,7 +573,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg)) { $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } // Parameters $object->sendtoid defined by caller @@ -624,7 +587,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -637,7 +599,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -654,7 +615,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -669,7 +629,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -686,7 +645,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day'); - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -701,7 +659,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -716,7 +673,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -732,7 +688,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -746,7 +701,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -759,7 +713,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectModifieddInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -775,7 +728,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -789,7 +741,6 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } @@ -803,18 +754,24 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; - $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; } - - // The trigger was enabled but we are missing the implementation, let the log know - else - { - dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.", LOG_WARNING); - return 0; + // TODO Merge all previous cases into this generic one + else { + // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) + $langs->load("agenda"); + $langs->load("other"); + + $object->actiontypecode='AC_OTH_AUTO'; + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); + + $object->sendtoid=0; } - + + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Add entry in event table diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index db2328cdfb4..9a2433994bd 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -444,14 +444,16 @@ if (empty($reshook)) $destinataire->fetch($object->fk_user_validator); $emailTo = $destinataire->email; - if ($emailTo) - { - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_author); + $emailFrom = $expediteur->email; - // SUBJECT + if ($emailFrom && $emailTo) + { + $filename=array(); $filedir=array(); $mimetype=array(); + + // SUBJECT $subject = $langs->transnoentities("ExpenseReportWaitingForReApproval"); // CONTENT @@ -561,73 +563,83 @@ if (empty($reshook)) // CC $emailCC = $conf->global->NDF_CC_EMAILS; + if (empty($emailTo)) $emailTo=$emailCC; // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_valid); $emailFrom = $expediteur->email; - // SUBJECT - $subject = $langs->transnoentities("ExpenseReportApproved"); - - // CONTENT - $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); - - // Rebuilt pdf - /* - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF - { - // ATTACHMENT + if ($emailFrom && $emailTo) + { $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); - array_push($mimetype,"application/pdf"); - } - */ + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportApproved"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if ($mailfile) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } - } + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
    '.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } - else - { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; - } - } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } + } else { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + setEventMessages($langs->trans("FailedtoSetToApprove"), null, 'warnings'); $action=''; } } @@ -677,68 +689,78 @@ if (empty($reshook)) $expediteur->fetch($object->fk_user_refuse); $emailFrom = $expediteur->email; - // SUBJECT - $subject = $langs->transnoentities("ExpenseReportRefused"); - - // CONTENT - $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); - - // Rebuilt pdf - /* - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF - { - // ATTACHMENT + if ($emailFrom && $emailTo) + { $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); - array_push($mimetype,"application/pdf"); - } - */ + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportRefused"); - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); - if ($mailfile) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } - } - } - else - { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; - } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
    '.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } } else { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + setEventMessages($langs->trans("FailedtoSetToDeny"), null, 'warnings'); + $action=''; } } else @@ -790,67 +812,77 @@ if (empty($reshook)) $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; - // SUBJECT - $subject = $langs->transnoentities("ExpenseReportCanceled"); - - // CONTENT - $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); - - // Rebuilt pdf - /* - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF - { - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); - array_push($mimetype,"application/pdf"); - } - */ - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if ($mailfile) + if ($emailFrom && $emailTo) { - // SEND - $result=$mailfile->sendfile(); - if ($result) + $filename=array(); $filedir=array(); $mimetype=array(); + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportCanceled"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
    '.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; - } + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } } else { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + setEventMessages($langs->trans("FailedToSetToCancel"), null, 'warnings'); $action=''; } } @@ -945,63 +977,73 @@ if (empty($reshook)) $expediteur->fetch($user->id); $emailFrom = $expediteur->email; - // SUBJECT - $subject = $langs->transnoentities("ExpenseReportPaid"); - - // CONTENT - $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; - $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Generate pdf before attachment - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if ($mailfile) + if ($emailFrom && $emailTo) { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } - } + $filename=array(); $filedir=array(); $mimetype=array(); + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportPaid"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; + $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Generate pdf before attachment + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
    '.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } else { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + setEventMessages($langs->trans("FailedToSetPaid"), null, 'warnings'); $action=''; } } diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 9aadb0c083e..d25963e8c3a 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -78,6 +78,10 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',35); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',40); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',42); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_DELETE','Project deleted','Executed when a project is deleted','project',143); -- actions not enabled by default (no constant created for that) when we enable module agenda diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index b20da8b9b89..71f9a17273c 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -42,10 +42,22 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label); +ALTER TABLE llx_holiday ADD COLUMN import_key varchar(14); +ALTER TABLE llx_holiday ADD COLUMN extraparams varchar(255); + +ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); +ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); + + insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204); + ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text; ALTER TABLE llx_loan ADD COLUMN fk_projet integer DEFAULT NULL; @@ -111,6 +123,16 @@ INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES ( ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CREATE' ,'Leave request created','Executed when a leave request is created','holiday',221); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Leave request validated','Executed when a leave request is validated','holiday',222); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE' ,'Leave request approved','Executed when a leave request is approved','holiday',223); + + ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier_line integer; ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier integer; ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier_source integer; diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql index 2a981444df3..2091dea9541 100644 --- a/htdocs/install/mysql/tables/llx_holiday.sql +++ b/htdocs/install/mysql/tables/llx_holiday.sql @@ -40,6 +40,8 @@ fk_user_cancel integer DEFAULT NULL, detail_refuse varchar( 250 ) DEFAULT NULL, note_private text, note_public text, -tms timestamp +tms timestamp, +import_key varchar(14), +extraparams varchar(255) -- for other parameters with json format ) ENGINE=innodb; From 166f2d262d7d3c4664ae1eb21d3f597906e3daa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 2 May 2017 14:00:27 +0200 Subject: [PATCH 105/172] Corrected PHP7 warnings for function CommonObject::getTotalWeightVolume --- htdocs/core/class/commonobject.class.php | 33 ++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60247186734..f2e8f75f796 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2953,24 +2953,31 @@ abstract class CommonObject */ function getTotalWeightVolume() { - $weightUnit=0; - $volumeUnit=0; - $totalWeight = ''; - $totalVolume = ''; - $totalOrdered = ''; // defined for shipment only - $totalToShip = ''; // defined for shipment only + $totalWeight = 0; + $totalVolume = 0; + // defined for shipment only + $totalOrdered = 0; + // defined for shipment only + $totalToShip = 0; foreach ($this->lines as $line) { - $totalOrdered+=$line->qty_asked; // defined for shipment only - $totalToShip+=$line->qty_shipped; // defined for shipment only + $totalOrdered+=$line->qty_asked ?: 0; // defined for shipment only + $totalToShip+= $line->qty_shipped ?: 0; // defined for shipment only + + // Define qty, weight, volume, weight_units, volume_units + if ($this->element == 'shipping') { + // for shipments + $qty = $line->qty_shipped ?: 0; + } + else { + $qty = $line->qty ?: 0; + } + + $weight = $line->weight ?: 0; + $volume = $line->volume ?: 0; - // Define qty, weight, volume, weight_units, volume_units - if ($this->element == 'shipping') $qty=$line->qty_shipped; // for shipments - else $qty=$line->qty; - $weight=$line->weight; - $volume=$line->volume; $weight_units=$line->weight_units; $volume_units=$line->volume_units; From 6e7fddee7d10cc2244f42a9d80f3eb5c6fe386ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 2 May 2017 14:07:04 +0200 Subject: [PATCH 106/172] Corrected PHP7 warnings for function pdf_einstein::write_file --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/theme/eldy/style.css.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 7d38fe03d2d..244e78caacb 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -483,7 +483,7 @@ class pdf_einstein extends ModelePDFCommandes $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]= 0; $this->tva[$vatrate] += $tvaligne; // Add line diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 76cbad28f00..d03ff95a50f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -158,25 +158,25 @@ if (! empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) // Set text color to black or white $tmppart=explode(',',$colorbackhmenu1); -$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); +$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0)+(! empty($tmppart[3]) ? $tmppart[3] : 0); if ($tmpval <= 360) $colortextbackhmenu='FFFFFF'; else $colortextbackhmenu='000000'; $tmppart=explode(',',$colorbackvmenu1); -$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); +$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0)+(! empty($tmppart[3]) ? $tmppart[3] : 0); if ($tmpval <= 360) { $colortextbackvmenu='FFFFFF'; } else { $colortextbackvmenu='000000'; } $tmppart=explode(',',$colorbacktitle1); if ($colortexttitle == '') { - $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); + $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0)+(! empty($tmppart[3]) ? $tmppart[3] : 0); if ($tmpval <= 360) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; } else { $colortexttitle='000000'; $colorshadowtitle='FFFFFF'; } } $tmppart=explode(',',$colorbacktabcard1); -$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); +$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0)+(! empty($tmppart[3]) ? $tmppart[3] : 0); if ($tmpval <= 340) { $colortextbacktab='FFFFFF'; } else { $colortextbacktab='111111'; } From 7ae405a254fb028b735faa9191a19529b8b7d5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 2 May 2017 14:08:20 +0200 Subject: [PATCH 107/172] Corrected PHP7 warnings for several PDF document models --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php | 2 +- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d50ddcfb2a0..52971f76770 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -585,7 +585,7 @@ class pdf_crabe extends ModelePDFFactures $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 000395a4fd4..f0fe0c33c51 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -574,7 +574,7 @@ class pdf_azur extends ModelePDFPropales $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index ba9e53bcc4d..fdf4f07cc86 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -466,7 +466,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index bc78730ba57..3a3c904e74a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -489,7 +489,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; From ad095d7fb24752c60085f54c44ce9604545970bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 14:26:51 +0200 Subject: [PATCH 108/172] NEW Can set margins of PDFs --- htdocs/admin/pdf.php | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b0c32a344ff..2e650c75696 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -42,15 +42,25 @@ $langs->load("members"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); + /* * Actions */ +if ($cancel) { + $action=''; +} + if ($action == 'update') { dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity); - + + dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity); @@ -133,7 +143,20 @@ if ($action == 'edit') // Edit print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT'); print ''; - print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + print ''; + print ''; + + print ''; print '
    '; @@ -270,7 +293,9 @@ if ($action == 'edit') // Edit print ''; print '
    '; - print ''; + print ''; + print '   '; + print ''; print '
    '; print ''; @@ -314,6 +339,20 @@ else // Show print $pdfformatlabel; print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + print empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM; + print ''; + + print ''; print '
    '; From 6138d197e4c7290e0a7a5ca3f5ecef45facff734 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Tue, 2 May 2017 15:19:55 +0200 Subject: [PATCH 109/172] FIX major issues for inventory - Move all needed declaration from coreobject to commonobject for updateCommon, fetchCommon, deleteCommon, createCommon - Just leave method for child object into coreobject, check later if is useless - debug inventory card, PHP 7.0 compatibility - activate rights for inventory into stock module - add inventory options into stock admin module --- htdocs/admin/inventory.php | 152 -------- htdocs/admin/stock.php | 56 +++ htdocs/core/class/commonobject.class.php | 330 +++++++++++++++--- htdocs/core/class/coreobject.class.php | 255 +------------- htdocs/core/modules/modStock.class.php | 65 +--- .../product/inventory/ajax/ajax.inventory.php | 10 +- htdocs/product/inventory/card.php | 7 +- 7 files changed, 370 insertions(+), 505 deletions(-) delete mode 100644 htdocs/admin/inventory.php diff --git a/htdocs/admin/inventory.php b/htdocs/admin/inventory.php deleted file mode 100644 index 2548494fc79..00000000000 --- a/htdocs/admin/inventory.php +++ /dev/null @@ -1,152 +0,0 @@ - - * Copyright (C) 2015 ATM Consulting - * - * 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 admin/inventory.php - * \ingroup inventory - * \brief This file is an example module setup page - * Put some comments here - */ -// Dolibarr environment -require '../main.inc.php'; - - -// Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; -require_once DOL_DOCUMENT_ROOT .'/inventory/lib/inventory.lib.php'; - -// Translations -$langs->load("stock"); -$langs->load("inventory"); - -// Access control -if (! $user->admin) { - accessforbidden(); -} - -// Parameters -$action = GETPOST('action', 'alpha'); - -/* - * Actions - */ -if (preg_match('/set_(.*)/',$action,$reg)) -{ - $code=$reg[1]; - if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } -} - -if (preg_match('/del_(.*)/',$action,$reg)) -{ - $code=$reg[1]; - if (dolibarr_del_const($db, $code, 0) > 0) - { - Header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } -} - -/* - * View - */ -$page_name = "inventorySetup"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = '' - . $langs->trans("BackToModuleList") . ''; -print_fiche_titre($langs->trans($page_name), $linkback); - -// Configuration header -$head = inventoryAdminPrepareHead(); -dol_fiche_head( - $head, - 'settings', - $langs->trans("Module104420Name"), - 0, - "inventory@inventory" -); - -// Setup page goes here -$form=new Form($db); -$var=false; -print ''; -print ''; -print ''."\n"; -print ''; -print ''."\n"; - -// Example with a yes / no select -$var=!$var; -print ''; -print ''; -print ''; -print ''; - -// Example with a yes / no select -$var=!$var; -print ''; -print ''; -print ''; -print ''; - -// Example with a yes / no select -$var=!$var; -print ''; -print ''; -print ''; -print ''; - -print '
    '.$langs->trans("Parameters").' '.$langs->trans("Value").'
    '.$langs->trans("INVENTORY_DISABLE_VIRTUAL").' '; -print '
    '; -print ''; -print ''; -print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1); -print ''; -print '
    '; -print '
    '.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; -print '
    '; -print ''; -print ''; -print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1); -print ''; -print '
    '; -print '
    '.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; -print '
    '; -print ''; -print ''; -print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1); -print ''; -print '
    '; -print '
    '; - -llxFooter(); - -$db->close(); \ No newline at end of file diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 1c5a92fb0e8..c8204f213c2 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -432,6 +432,61 @@ if ($virtualdiffersfromphysical) } +print '
    '; +if ($conf->global->MAIN_LEVEL_FEATURES >= 2) +{ + $var=false; + print ''; + print ''; + print ''."\n"; + print ''; + print ''."\n"; + + // Example with a yes / no select + $var=!$var; + print ''; + print ''; + print ''; + print ''; + + // Example with a yes / no select + $var=!$var; + print ''; + print ''; + print ''; + print ''; + + // Example with a yes / no select + $var=!$var; + print ''; + print ''; + print ''; + print ''; + + print '
    '.$langs->trans("Inventory").'  
    '.$langs->trans("INVENTORY_DISABLE_VIRTUAL").' '; + print '
    '; + print ''; + print ''; + print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1); + print ''; + print '
    '; + print '
    '.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; + print '
    '; + print ''; + print ''; + print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1); + print ''; + print '
    '; + print '
    '.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; + print '
    '; + print ''; + print ''; + print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1); + print ''; + print '
    '; + print '
    '; +} + $var=true; print ''; @@ -508,6 +563,7 @@ if ($conf->global->PRODUIT_SOUSPRODUITS) print '
    '; + llxFooter(); $db->close(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5e5c13056e7..582e00d29fa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Bahfir abbes + * Copyright (C) 2017 ATM Consulting * * 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 @@ -4662,7 +4663,159 @@ abstract class CommonObject return $buyPrice; } + /** + * Function test if type is date + * + * @param array $info content informations of field + * @return bool + */ + protected function is_date($info) + { + if(isset($info['type']) && $info['type']=='date') return true; + else return false; + } + /** + * Function test if type is array + * + * @param array $info content informations of field + * @return bool + */ + protected function is_array($info) + { + if(is_array($info)) + { + if(isset($info['type']) && $info['type']=='array') return true; + else return false; + } + else return false; + } + + /** + * Function test if type is null + * + * @param array $info content informations of field + * @return bool + */ + protected function is_null($info) + { + if(is_array($info)) + { + if(isset($info['type']) && $info['type']=='null') return true; + else return false; + } + else return false; + } + + /** + * Function test if type is integer + * + * @param array $info content informations of field + * @return bool + */ + protected function is_int($info) + { + if(is_array($info)) + { + if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true; + else return false; + } + else return false; + } + + /** + * Function test if type is float + * + * @param array $info content informations of field + * @return bool + */ + protected function is_float($info) + { + if(is_array($info)) + { + if(isset($info['type']) && $info['type']=='float') return true; + else return false; + } + else return false; + } + + /** + * Function test if type is text + * + * @param array $info content informations of field + * @return bool + */ + protected function is_text($info) + { + if(is_array($info)) + { + if(isset($info['type']) && $info['type']=='text') return true; + else return false; + } + else return false; + } + + /** + * Function test if is indexed + * + * @param array $info content informations of field + * @return bool + */ + protected function is_index($info) + { + if(is_array($info)) + { + if(isset($info['index']) && $info['index']==true) return true; + else return false; + } + else return false; + } + + /** + * Function to prepare the values to insert + * + * @return array + */ + private function set_save_query() + { + $query=array(); + foreach ($this->fields as $field=>$info) + { + if($this->is_date($info)) + { + if(empty($this->{$field})) + { + $query[$field] = NULL; + } + else + { + $query[$field] = $this->db->idate($this->{$field}); + } + } + else if($this->is_array($info)) + { + $query[$field] = serialize($this->{$field}); + } + else if($this->is_int($info)) + { + $query[$field] = (int) price2num($this->{$field}); + } + else if($this->is_float($info)) + { + $query[$field] = (double) price2num($this->{$field}); + } + elseif($this->is_null($info)) + { + $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field}); + } + else + { + $query[$field] = $this->{$field}; + } + } + + return $query; + } /** * Create object into database @@ -4674,28 +4827,82 @@ abstract class CommonObject */ public function createCommon(User $user, $notrigger = false) { - foreach ($this->fields as $k => $v) { - $keys[] = $k; - $values[] = $this->quote($v); - + $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); + + foreach ($fields as $k => $v) { + + $keys[] = $k; + $values[] = $this->quote($v); + } - - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.' + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' ( '.implode( ",", $keys ).' ) VALUES ( '.implode( ",", $values ).' ) '; - - $res = $this->query($sql); + $res = $this->db->query( $sql ); if($res===false) { - - return false; + + return false; } // TODO Add triggers - - return true; + + return true; + } + /** + * Function to load data into current object this + * + * @param stdClass $obj Contain data of object from database + */ + private function set_vars_by_db(&$obj) + { + foreach ($this->fields as $field => $info) + { + if($this->is_date($info)) + { + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; + else $this->{$field} = strtotime($obj->{$field}); + } + elseif($this->is_array($info)) + { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + } + elseif($this->is_int($info)) + { + $this->{$field} = (int) $obj->{$field}; + } + elseif($this->is_float($info)) + { + $this->{$field} = (double) $obj->{$field}; + } + elseif($this->is_null($info)) + { + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); + } + else + { + $this->{$field} = $obj->{$field}; + } + + } + } + + /** + * Function to concat keys of fields + * + * @return string + */ + private function get_field_list() + { + $keys = array_keys($this->fields); + return implode(',', $keys); + } /** * Load object in memory from the database @@ -4708,6 +4915,32 @@ abstract class CommonObject public function fetchCommon($id, $ref = null) { + if (empty($id) && empty($ref)) return false; + + $sql = 'SELECT '.$this->get_field_list().', datec, tms'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; + + if(!empty($id)) $sql.= ' WHERE rowid = '.$id; + else $sql.= ' WHERE ref = \''.$this->quote($ref).'\''; + + $res = $this->db->query($sql); + if($obj = $this->db->fetch_object($res)) + { + $this->id = $id; + $this->set_vars_by_db($obj); + + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); + + return $this->id; + } + else + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } + } /** @@ -4720,34 +4953,36 @@ abstract class CommonObject */ public function updateCommon(User $user, $notrigger = false) { - foreach ($this->fields as $k => $v) { - - if (is_array($key)){ - $i=array_search($k, $key); - if ( $i !== false) { - $where[] = $key[$i].'=' . $this->quote( $v ) ; - continue; - } - } else { - if ( $k == $key) { - $where[] = $k.'=' .$this->quote( $v ) ; - continue; - } - } - - $tmp[] = $k.'='.$this->quote($v); - } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ; - $res = $this->query( $sql ); - - if($res===false) { - //error - return false; - } - - // TODO Add triggers - - return true; + $fields = $this->set_save_query(); + + foreach ($fields as $k => $v) { + + if (is_array($key)){ + $i=array_search($k , $key ); + if ( $i !== false) { + $where[] = $key[$i].'=' . $this->quote( $v ) ; + continue; + } + } else { + if ( $k == $key) { + $where[] = $k.'=' .$this->quote( $v ) ; + continue; + } + } + + $tmp[] = $k.'='.$this->quote($v); + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; + $res = $this->db->query( $sql ); + + if($res===false) { + //error + return false; + } + + // TODO Add triggers + + return true; } /** @@ -4760,7 +4995,16 @@ abstract class CommonObject */ public function deleteCommon(User $user, $notrigger = false) { - + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query( $sql ); + if($res===false) { + return false; + } + + // TODO Add triggers + + return true; } /** @@ -4769,11 +5013,11 @@ abstract class CommonObject * @param string|int $value value to protect * @return string|int */ - function quote($value) { + protected function quote($value) { if(is_null($value)) return 'NULL'; else if(is_numeric($value)) return $value; - else return "'".$this->escape( $value )."'"; + else return "'".$this->db->escape( $value )."'"; } diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 8aa0cfe2ad6..c86a1083519 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -97,216 +97,6 @@ class CoreObject extends CommonObject } } - /** - * Function test if type is date - * - * @param array $info content informations of field - * @return bool - */ - private function is_date($info) - { - if(isset($info['type']) && $info['type']=='date') return true; - else return false; - } - - /** - * Function test if type is array - * - * @param array $info content informations of field - * @return bool - */ - private function is_array($info) - { - if(is_array($info)) - { - if(isset($info['type']) && $info['type']=='array') return true; - else return false; - } - else return false; - } - - /** - * Function test if type is null - * - * @param array $info content informations of field - * @return bool - */ - private function is_null($info) - { - if(is_array($info)) - { - if(isset($info['type']) && $info['type']=='null') return true; - else return false; - } - else return false; - } - - /** - * Function test if type is integer - * - * @param array $info content informations of field - * @return bool - */ - private function is_int($info) - { - if(is_array($info)) - { - if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true; - else return false; - } - else return false; - } - - /** - * Function test if type is float - * - * @param array $info content informations of field - * @return bool - */ - private function is_float($info) - { - if(is_array($info)) - { - if(isset($info['type']) && $info['type']=='float') return true; - else return false; - } - else return false; - } - - /** - * Function test if type is text - * - * @param array $info content informations of field - * @return bool - */ - private function is_text($info) - { - if(is_array($info)) - { - if(isset($info['type']) && $info['type']=='text') return true; - else return false; - } - else return false; - } - - /** - * Function test if is indexed - * - * @param array $info content informations of field - * @return bool - */ - private function is_index($info) - { - if(is_array($info)) - { - if(isset($info['index']) && $info['index']==true) return true; - else return false; - } - else return false; - } - - - /** - * Function to prepare the values to insert - * - * @return array - */ - private function set_save_query() - { - $query=array(); - foreach ($this->fields as $field=>$info) - { - if($this->is_date($info)) - { - if(empty($this->{$field})) - { - $query[$field] = NULL; - } - else - { - $query[$field] = $this->db->idate($this->{$field}); - } - } - else if($this->is_array($info)) - { - $query[$field] = serialize($this->{$field}); - } - else if($this->is_int($info)) - { - $query[$field] = (int) price2num($this->{$field}); - } - else if($this->is_float($info)) - { - $query[$field] = (double) price2num($this->{$field}); - } - elseif($this->is_null($info)) - { - $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field}); - } - else - { - $query[$field] = $this->{$field}; - } - } - - return $query; - } - - - /** - * Function to concat keys of fields - * - * @return string - */ - private function get_field_list() - { - $keys = array_keys($this->fields); - return implode(',', $keys); - } - - - /** - * Function to load data into current object this - * - * @param stdClass $obj Contain data of object from database - */ - private function set_vars_by_db(&$obj) - { - foreach ($this->fields as $field => $info) - { - if($this->is_date($info)) - { - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; - else $this->{$field} = strtotime($obj->{$field}); - } - elseif($this->is_array($info)) - { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); - } - elseif($this->is_int($info)) - { - $this->{$field} = (int) $obj->{$field}; - } - elseif($this->is_float($info)) - { - $this->{$field} = (double) $obj->{$field}; - } - elseif($this->is_null($info)) - { - $val = $obj->{$field}; - // zero is not null - $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); - } - else - { - $this->{$field} = $obj->{$field}; - } - - } - } - /** * Get object and children from database * @@ -316,31 +106,14 @@ class CoreObject extends CommonObject */ public function fetch($id, $loadChild = true) { - if (empty($id)) return false; - - $sql = 'SELECT '.$this->get_field_list().', datec, tms'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' WHERE rowid = '.$id; - $res = $this->db->query($sql); - if($obj = $this->db->fetch_object($res)) - { - $this->id = $id; - $this->set_vars_by_db($obj); - - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); - - if ($loadChild) $this->fetchChild(); - - return $this->id; - } - else - { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; - } + $res = $this->fetchCommon($id); + if($res>0) { + if ($loadChild) $this->fetchChild(); + } + + return $res; + } @@ -473,10 +246,7 @@ class CoreObject extends CommonObject $error = 0; $this->db->begin(); - $query = $this->set_save_query(); - $query['rowid'] = $this->id; - - $res = $this->db->update($this->table_element, $query, array('rowid')); + $res = $this->updateCommon($user); if ($res) { $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); @@ -516,10 +286,7 @@ class CoreObject extends CommonObject $error = 0; $this->db->begin(); - $query = $this->set_save_query(); - $query['datec'] = date("Y-m-d H:i:s", dol_now()); - - $res = $this->db->insert($this->table_element, $query); + $res = $this->createCommon($user); if($res) { $this->id = $this->db->last_insert_id($this->table_element); @@ -565,7 +332,7 @@ class CoreObject extends CommonObject if (!$error) { - $this->db->delete($this->table_element, array('rowid' => $this->id), array('rowid')); + $this->deleteCommon($user); if($this->withChild && !empty($this->childtables)) { foreach($this->childtables as &$childTable) @@ -669,5 +436,5 @@ class CoreObject extends CommonObject return 1; } - + } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index cfdc6db298c..ea181f72a41 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -117,91 +117,42 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; - /* - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + + $this->rights[$r][0] = 1006; $this->rights[$r][1] = 'inventoryReadPermission'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 1007; $this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 1008; $this->rights[$r][1] = 'inventoryWritePermission'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 1009; $this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 1010; $this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - */ + // Main menu entries $this->menu = array(); // List of menus to add $r=0; - /* - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=products', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'Inventory', - 'mainmenu'=>'products', - 'leftmenu'=>'inventory_left', - 'url'=>'/inventory/list.php', - 'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100+$r, - 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2 - ); // 0=Menu for internal users, 1=external users, 2=both - $r++; - - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'NewInventory', - 'mainmenu'=>'products', - 'leftmenu'=>'inventory_left_create', - 'url'=>'/inventory/inventory.php?action=create', - 'position'=>100+$r, - 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2 - ); // 0=Menu for internal users, 1=external users, 2=both - $r++; - - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'ListInventory', - 'mainmenu'=>'products', - 'leftmenu'=>'inventory_left_list', - 'url'=>'/inventory/list.php', - 'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100+$r, - 'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2 - ); // 0=Menu for internal users, 1=external users, 2=both - $r++; - */ - // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. diff --git a/htdocs/product/inventory/ajax/ajax.inventory.php b/htdocs/product/inventory/ajax/ajax.inventory.php index c0d8443f433..4884d7ab065 100644 --- a/htdocs/product/inventory/ajax/ajax.inventory.php +++ b/htdocs/product/inventory/ajax/ajax.inventory.php @@ -2,14 +2,14 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; - + $get = GETPOST('get'); $put = GETPOST('put'); switch ($put) { case 'qty': - if (empty($user->rights->stock->write)) { echo -1; exit; } + if (empty($user->rights->stock->creer)) { echo -1; exit; } $fk_det_inventory = GETPOST('fk_det_inventory'); @@ -17,7 +17,7 @@ if( $det->fetch( $fk_det_inventory)) { $det->qty_view+=GETPOST('qty'); - $det->update($user); + $res = $det->update($user); echo $det->qty_view; } @@ -25,11 +25,11 @@ { echo -2; } - + break; case 'pmp': - if (!$user->rights->stock->write || !$user->rights->stock->changePMP) { echo -1; exit; } + if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; } $fk_det_inventory = GETPOST('fk_det_inventory'); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index dc279cc0929..ad539532901 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -66,7 +66,7 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('inventory')); +$hookmanager->initHooks(array('inventorycard')); @@ -84,7 +84,7 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1); header("Location: ".$urltogo); exit; } @@ -98,7 +98,7 @@ if (empty($reshook)) if ($cancel) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1); header("Location: ".$urltogo); exit; } @@ -128,7 +128,6 @@ if (empty($reshook)) exit; } - break; } switch($action) { From 12e91f1c1b9f5c02f0e47f6c33ea0cce7b26fafa Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Tue, 2 May 2017 15:25:30 +0200 Subject: [PATCH 110/172] fix rights inventory only for MAIN_LEVEL_FEATURES = 2 --- htdocs/core/modules/modStock.class.php | 47 ++++++++++++-------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ea181f72a41..e80966afb81 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -117,37 +117,34 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; + if ($conf->global->MAIN_LEVEL_FEATURES >= 2) { - $this->rights[$r][0] = 1006; - $this->rights[$r][1] = 'inventoryReadPermission'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r++; + $this->rights[5][0] = 1006; + $this->rights[5][1] = 'inventoryReadPermission'; // Permission label + $this->rights[5][3] = 0; // Permission by default for new user (0/1) + $this->rights[5][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][0] = 1007; - $this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r++; + $this->rights[6][0] = 1007; + $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label + $this->rights[6][3] = 0; // Permission by default for new user (0/1) + $this->rights[6][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][0] = 1008; - $this->rights[$r][1] = 'inventoryWritePermission'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r++; + $this->rights[7][0] = 1008; + $this->rights[7][1] = 'inventoryWritePermission'; // Permission label + $this->rights[7][3] = 0; // Permission by default for new user (0/1) + $this->rights[7][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][0] = 1009; - $this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r++; + $this->rights[7][0] = 1009; + $this->rights[7][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[7][3] = 0; // Permission by default for new user (0/1) + $this->rights[7][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][0] = 1010; - $this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r++; + $this->rights[7][0] = 1010; + $this->rights[7][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[7][3] = 0; // Permission by default for new user (0/1) + $this->rights[7][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + } // Main menu entries $this->menu = array(); // List of menus to add From c673d283e01e41a6292875dce4b9a8bb07bcf817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 18:21:50 +0200 Subject: [PATCH 111/172] Fix script to send emailings --- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- scripts/emailings/mailing-send.php | 41 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bce6d69b2fa..9da1ada59ad 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -48,7 +48,7 @@ class InterfaceActionsAuto extends DolibarrTriggers * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact or array of ids) - * $object->socid + * $object->socid (id of thirdparty) * $object->fk_project * $object->fk_element * $object->elementtype diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 27cc22448e6..6465e765cfe 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -41,11 +41,12 @@ if (! isset($argv[1]) || ! $argv[1]) { exit(-1); } $id=$argv[1]; -if (! isset($argv[2]) || !empty($argv[2])) $login = $argv[2]; +if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2]; else $login = ''; require_once ($path."../../htdocs/master.inc.php"); require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require_once (DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php"); // Global variables @@ -70,9 +71,8 @@ $user = new User($db); // for signature, we use user send as parameter if (! empty($login)) $user->fetch('',$login); -// We get list of emailing to process -$sql = "SELECT m.rowid, m.titre, m.sujet, m.body,"; -$sql.= " m.email_from, m.email_replyto, m.email_errorsto"; +// We get list of emailing id to process +$sql = "SELECT m.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " WHERE m.statut IN (1,2)"; if ($id != 'all') @@ -96,12 +96,15 @@ if ($resql) dol_syslog("Process mailing with id ".$obj->rowid); print "Process mailing with id ".$obj->rowid."\n"; - $id = $obj->rowid; - $subject = $obj->sujet; - $message = $obj->body; - $from = $obj->email_from; - $replyto = $obj->email_replyto; - $errorsto = $obj->email_errorsto; + $emailing = new Mailing($db); + $emailing->fetch($obj->rowid); + + $id = $emailing->id; + $subject = $emailing->sujet; + $message = $emailing->body; + $from = $emailing->email_from; + $replyto = $emailing->email_replyto; + $errorsto = $emailing->email_errorsto; // Le message est-il en html $msgishtml=-1; // Unknown by default if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; @@ -232,6 +235,24 @@ if ($resql) dol_syslog("ok for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + // Note: If emailing is 100 000 targets, 100 000 entries are added, so we don't enter events for each target here + // We must union table llx_mailing_taget for event tab OR enter 1 event with a special table link (id of email in event) + // Run trigger + /* + if ($obj2->source_type == 'contact') + { + $emailing->sendtoid = $obj2->source_id; + } + if ($obj2->source_type == 'thirdparty') + { + $emailing->socid = $obj2->source_id; + } + // Call trigger + $result=$emailing->call_trigger('EMAILING_SENTBYMAIL',$user); + if ($result < 0) $error++; + // End call triggers + */ + $sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj2->rowid; $resqlok=$db->query($sqlok); From 0bc46facd75af8117780da5e4b30af9011645bd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:24:18 +0200 Subject: [PATCH 112/172] Add missing vat_src_code on recurring invoices --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_facture_rec.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 71f9a17273c..991381cb432 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -141,6 +141,8 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_soc_remise_fk_invoice_su ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); +ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; + UPDATE llx_const set value='moono-lisa' where value = 'moono' AND name = 'FCKEDITOR_SKIN'; ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index d0d79ef57dc..0e25100386b 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -32,6 +32,7 @@ create table llx_facture_rec remise_percent real DEFAULT 0, remise_absolue real DEFAULT 0, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, -- amount localtax1 localtax2 double(24,8) DEFAULT 0, -- amount localtax2 From b8f5e93ab0b56157dbfa83d95da42df84ff57487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:40:18 +0200 Subject: [PATCH 113/172] Debug inventory data model --- htdocs/install/mysql/data/llx_c_tva.sql | 2 +- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 13 +++++++++---- htdocs/install/mysql/tables/llx_inventorydet.sql | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 34842ed324e..3b401abd37d 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -96,11 +96,11 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (80 -- FRANCE (id country=1) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1); -insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values ( 12, 1, '8.5', '8.5', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT reduced rate (France hors DOM-TOM)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 16, 1, '2.1','0','VAT super-reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 17, 1, '10','0','VAT reduced rate',1); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 991381cb432..1982ef6aff8 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -229,9 +229,9 @@ fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, batch varchar(30) DEFAULT NULL, -qty_view double DEFAULT 0, -qty_stock double DEFAULT 0, -qty_regulated double DEFAULT 0, +qty_view double DEFAULT NULL, +qty_stock double DEFAULT NULL, +qty_regulated double DEFAULT NULL, pmp double DEFAULT 0, pa double DEFAULT 0, new_pmp double DEFAULT 0 @@ -242,4 +242,9 @@ ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms); ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); -ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); \ No newline at end of file +ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); + +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); diff --git a/htdocs/install/mysql/tables/llx_inventorydet.sql b/htdocs/install/mysql/tables/llx_inventorydet.sql index 2b203e0c58b..ce40d03939c 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet.sql @@ -25,10 +25,10 @@ tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, -batch varchar(30) DEFAULT NULL, -- Lot or serial number -qty_view double DEFAULT 0, -qty_stock double DEFAULT 0, -qty_regulated double DEFAULT 0, +batch varchar(30) DEFAULT NULL, -- Lot or serial number +qty_view double DEFAULT NULL, -- must be filled once regulation is done +qty_stock double DEFAULT NULL, -- can be filled during draft edition +qty_regulated double DEFAULT NULL, -- must be filled once regulation is done pmp double DEFAULT 0, pa double DEFAULT 0, new_pmp double DEFAULT 0 From a115d4877b9903dfb137e9ecb2d0cd2fb03db4c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 22:37:23 +0200 Subject: [PATCH 114/172] Fix for new property array fields --- htdocs/api/class/api.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 7aef2671c8d..9228c71ccbf 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -90,6 +90,8 @@ class DolibarrApi // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses unset($object->linkedObjects); + unset($object->fields); + unset($object->oldline); unset($object->error); From 3917bdfc7941e4dad37ddfc65383bcc44f62e3d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:27:56 +0200 Subject: [PATCH 115/172] Fix vat_src_code propagation. --- htdocs/comm/propal/card.php | 5 ++++- htdocs/comm/propal/class/propal.class.php | 14 ++++++++++---- htdocs/commande/card.php | 5 ++++- htdocs/commande/class/commande.class.php | 8 +++++++- htdocs/compta/facture.php | 17 ++++++++++++----- htdocs/compta/facture/class/facture.class.php | 7 +++++-- htdocs/core/class/commoninvoice.class.php | 6 ++++++ htdocs/core/class/commonobject.class.php | 5 ++++- htdocs/societe/soc.php | 4 ++-- 9 files changed, 54 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8c1c579b0c2..150abdf5f46 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -492,7 +492,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b63c59ecad4..4587e960c4c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -253,6 +253,8 @@ class Propal extends CommonObject $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); @@ -273,6 +275,7 @@ class Propal extends CommonObject $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->fk_unit=$prod->fk_unit; if ($tva_npr) $line->info_bits = 1; @@ -315,6 +318,7 @@ class Propal extends CommonObject $line->fk_propal=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->fk_product=0; // Id produit predefined @@ -698,7 +702,8 @@ class Propal extends CommonObject $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; - $this->line->product_type = $type; + $this->line->product_type = $type; + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; @@ -708,7 +713,6 @@ class Propal extends CommonObject $this->line->subprice = $pu_ht; $this->line->info_bits = $info_bits; - $this->line->vat_src_code = $vat_src_code; $this->line->total_ht = $total_ht; $this->line->total_tva = $total_tva; $this->line->total_localtax1 = $total_localtax1; @@ -1368,7 +1372,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; @@ -1404,6 +1408,7 @@ class Propal extends CommonObject $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3591,7 +3596,7 @@ class PropaleLigne extends CommonObjectLine */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.fk_unit,'; @@ -3617,6 +3622,7 @@ class PropaleLigne extends CommonObjectLine $this->qty = $objp->qty; $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 749f40fef4e..d99aa6a4f46 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -373,7 +373,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { $error++; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 462ba4756c5..c89fc8d11da 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1103,6 +1103,7 @@ class Commande extends CommonOrder $line->desc = $object->lines[$i]->desc; $line->price = $object->lines[$i]->price; $line->subprice = $object->lines[$i]->subprice; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1466,7 +1467,8 @@ class Commande extends CommonOrder $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); @@ -1485,6 +1487,7 @@ class Commande extends CommonOrder $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->localtax1_tx=$localtax1_tx; $line->localtax2_tx=$localtax2_tx; @@ -1703,6 +1706,7 @@ class Commande extends CommonOrder $line->fk_commande=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->price=-$remise->amount_ht; @@ -3809,6 +3813,7 @@ class OrderLine extends CommonOrderLine $this->qty = $objp->qty; $this->price = $objp->price; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; @@ -4120,6 +4125,7 @@ class OrderLine extends CommonOrderLine $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= " , vat_src_code=".(! empty($this->vat_src_code)?"'".$this->db->escape($this->vat_src_code)."'":"''"); $sql.= " , tva_tx=".price2num($this->tva_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b71dbe0cc70..05174fd940b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1050,11 +1050,14 @@ if (empty($reshook)) } } + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + $result = $object->addline( $langs->trans('Deposit'), $amountdeposit, // subprice 1, // quantity - $lines[$i]->tva_tx, // vat rate + $tva_tx, // vat rate 0, // localtax1_tx 0, // localtax2_tx (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product @@ -1150,11 +1153,15 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - // View third's localtaxes for now - $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->thirdparty); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + // View third's localtaxes for NOW and do not use value from origin. + // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b80919c48b4..bc4cf3626a4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -952,6 +952,7 @@ class Facture extends CommonInvoice $line->total_ht = $object->lines[$i]->total_ht; $line->total_tva = $object->lines[$i]->total_tva; $line->total_ttc = $object->lines[$i]->total_ttc; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1551,6 +1552,7 @@ class Facture extends CommonInvoice $facligne->fk_facture=$this->id; $facligne->fk_remise_except=$remise->id; $facligne->desc=$remise->description; // Description ligne + $facligne->vat_src_code=$remise->vat_src_code; $facligne->tva_tx=$remise->tva_tx; $facligne->subprice=-$remise->amount_ht; $facligne->fk_product=0; // Id produit predefini @@ -2399,7 +2401,7 @@ class Facture extends CommonInvoice * @param string $desc Description of line * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto + * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id of predefined product/service @@ -4276,7 +4278,7 @@ class FactureLigne extends CommonInvoiceLine */ function fetch($rowid) { - $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.tva_tx,'; + $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; @@ -4304,6 +4306,7 @@ class FactureLigne extends CommonInvoiceLine $this->desc = $objp->description; $this->qty = $objp->qty; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 05cf0b4c3cb..4dc330544ee 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -471,6 +471,12 @@ abstract class CommonInvoiceLine extends CommonObjectLine */ public $fk_product; + /** + * VAT code + * @var string + */ + public $vat_src_code; + /** * VAT % * @var float diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c9acc1f310e..1bf4a95a2c9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3567,7 +3567,7 @@ abstract class CommonObject print ''; print ''.$langs->trans('Ref').''; print ''.$langs->trans('Description').''; - print ''.$langs->trans('VAT').''; + print ''.$langs->trans('VATRate').''; print ''.$langs->trans('PriceUHT').''; if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency').''; print ''.$langs->trans('Qty').''; @@ -3698,7 +3698,10 @@ abstract class CommonObject $this->tpl['description'] = ' '; } + // VAT Rate $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; + $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b5bda51b4ba..b9c962a5168 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1743,7 +1743,7 @@ else //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { - print ''.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); if(! isOnlyOneLocalTax(1)) { @@ -1752,7 +1752,7 @@ else print ''; } - print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { From d1a443f0f042c939a491c9d7cdc30632bf9b64c8 Mon Sep 17 00:00:00 2001 From: alexis portable Date: Tue, 2 May 2017 23:11:05 +0200 Subject: [PATCH 116/172] fix camelcase for travis --- htdocs/core/class/commonobject.class.php | 34 ++++++++++++------------ htdocs/core/class/coreobject.class.php | 8 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 582e00d29fa..97c8da3f316 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4669,7 +4669,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_date($info) + protected function isDate($info) { if(isset($info['type']) && $info['type']=='date') return true; else return false; @@ -4681,7 +4681,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_array($info) + protected function isArray($info) { if(is_array($info)) { @@ -4697,7 +4697,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_null($info) + protected function isNull($info) { if(is_array($info)) { @@ -4713,7 +4713,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_int($info) + protected function isInt($info) { if(is_array($info)) { @@ -4729,7 +4729,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_float($info) + protected function isFloat($info) { if(is_array($info)) { @@ -4745,7 +4745,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_text($info) + protected function isText($info) { if(is_array($info)) { @@ -4761,7 +4761,7 @@ abstract class CommonObject * @param array $info content informations of field * @return bool */ - protected function is_index($info) + protected function isIndex($info) { if(is_array($info)) { @@ -4781,7 +4781,7 @@ abstract class CommonObject $query=array(); foreach ($this->fields as $field=>$info) { - if($this->is_date($info)) + if($this->isDate($info)) { if(empty($this->{$field})) { @@ -4792,19 +4792,19 @@ abstract class CommonObject $query[$field] = $this->db->idate($this->{$field}); } } - else if($this->is_array($info)) + else if($this->isArray($info)) { $query[$field] = serialize($this->{$field}); } - else if($this->is_int($info)) + else if($this->isInt($info)) { $query[$field] = (int) price2num($this->{$field}); } - else if($this->is_float($info)) + else if($this->isFloat($info)) { $query[$field] = (double) price2num($this->{$field}); } - elseif($this->is_null($info)) + elseif($this->isNull($info)) { $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field}); } @@ -4860,26 +4860,26 @@ abstract class CommonObject { foreach ($this->fields as $field => $info) { - if($this->is_date($info)) + if($this->isDate($info)) { if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; else $this->{$field} = strtotime($obj->{$field}); } - elseif($this->is_array($info)) + elseif($this->isArray($info)) { $this->{$field} = @unserialize($obj->{$field}); // Hack for data not in UTF8 if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); } - elseif($this->is_int($info)) + elseif($this->isInt($info)) { $this->{$field} = (int) $obj->{$field}; } - elseif($this->is_float($info)) + elseif($this->isFloat($info)) { $this->{$field} = (double) $obj->{$field}; } - elseif($this->is_null($info)) + elseif($this->isNull($info)) { $val = $obj->{$field}; // zero is not null diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index c86a1083519..021213594f7 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -59,10 +59,10 @@ class CoreObject extends CommonObject { foreach ($this->fields as $field=>$info) { - if ($this->is_date($info)) $this->{$field} = time(); - elseif ($this->is_array($info)) $this->{$field} = array(); - elseif ($this->is_int($info)) $this->{$field} = (int) 0; - elseif ($this->is_float($info)) $this->{$field} = (double) 0; + if ($this->isDate($info)) $this->{$field} = time(); + elseif ($this->isArray($info)) $this->{$field} = array(); + elseif ($this->isInt($info)) $this->{$field} = (int) 0; + elseif ($this->isFloat($info)) $this->{$field} = (double) 0; else $this->{$field} = ''; } From da4d179d36789551eb31490f107f7abd3c6a0c92 Mon Sep 17 00:00:00 2001 From: alexis portable Date: Tue, 2 May 2017 23:20:23 +0200 Subject: [PATCH 117/172] fix travis --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 97c8da3f316..16bff11b5fd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4958,7 +4958,7 @@ abstract class CommonObject foreach ($fields as $k => $v) { if (is_array($key)){ - $i=array_search($k , $key ); + $i=array_search($k, $key); if ( $i !== false) { $where[] = $key[$i].'=' . $this->quote( $v ) ; continue; From 98b2e83bfb657b3528c028c31f8945afd56e4062 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 3 May 2017 15:58:36 +1100 Subject: [PATCH 118/172] Fix localtaxes type not retrieved in proposals. Fixes Dolibarr/dolibarr/#6786 --- htdocs/comm/propal/class/propal.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b63c59ecad4..1ab2ae113cb 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1368,7 +1368,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; @@ -1407,6 +1407,8 @@ class Propal extends CommonObject $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; $line->fk_remise_except = $objp->fk_remise_except; $line->remise_percent = $objp->remise_percent; From f63f28c7febedd41e200c5274d2925494f7b1935 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 3 May 2017 21:34:57 +1100 Subject: [PATCH 119/172] Fix vat_src_code propagation between post types --- htdocs/comm/propal/class/propal.class.php | 6 ++++-- htdocs/commande/class/commande.class.php | 1 + htdocs/core/class/commonobject.class.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1ab2ae113cb..6443d3bcf4e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1368,7 +1368,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; @@ -1404,6 +1404,7 @@ class Propal extends CommonObject $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3593,7 +3594,7 @@ class PropaleLigne extends CommonObjectLine */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.fk_unit,'; @@ -3619,6 +3620,7 @@ class PropaleLigne extends CommonObjectLine $this->qty = $objp->qty; $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 462ba4756c5..1a0aef2ae48 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4120,6 +4120,7 @@ class OrderLine extends CommonOrderLine $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= " , vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; $sql.= " , tva_tx=".price2num($this->tva_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c9acc1f310e..35b7ddc98ae 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3698,7 +3698,7 @@ abstract class CommonObject $this->tpl['description'] = ' '; } - $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + $this->tpl['vat_rate'] = vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; From b93df2d6b5af7d0e7c5d185e62a27ef0a418dc8b Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 3 May 2017 23:13:21 +1100 Subject: [PATCH 120/172] Fixes localtax propagation to new invoice --- htdocs/compta/facture.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b71dbe0cc70..c1c14b7110d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1150,11 +1150,13 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - // View third's localtaxes for now - $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->thirdparty); + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); + // View third's localtaxes for now + $localtax1_tx = get_localtax($txtva, 1, $object->thirdparty); + $localtax2_tx = get_localtax($txtva, 2, $object->thirdparty); + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $txtva, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; From 421843e693c5c948c86bfb1d214c3cdee7dd4cdb Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 3 May 2017 23:35:57 +1100 Subject: [PATCH 121/172] Fix missing localtaxes lines in "commande" PDF --- htdocs/commande/class/commande.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1a0aef2ae48..0955fd18481 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1758,7 +1758,7 @@ class Commande extends CommonOrder $this->lines=array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; + $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; $sql.= ' l.fk_unit,'; $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; @@ -1795,9 +1795,11 @@ class Commande extends CommonOrder $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; - $line->total_ht = $objp->total_ht; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; + $line->total_ht = $objp->total_ht; $line->total_ttc = $objp->total_ttc; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; From 909b489d1f9fb74f4c9680e6a9fb0ff46c8797e8 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Thu, 4 May 2017 10:05:55 +1100 Subject: [PATCH 122/172] More fixes regarding localtaxes not being diplayed in generated PDF and vat_src_code not being propagating properly when generating posts from type to type. --- htdocs/commande/card.php | 8 +++++++- htdocs/contrat/card.php | 12 +++++++++--- htdocs/contrat/class/contrat.class.php | 8 +++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 749f40fef4e..05288f72f0e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -373,7 +373,13 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; + + // View third's localtaxes for now + $localtax1_tx = get_localtax($txtva, 1, $object->thirdparty); + $localtax2_tx = get_localtax($txtva, 2, $object->thirdparty); + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $txtva, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { $error++; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7a89ba9886f..322220c5d4f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -332,14 +332,20 @@ if (empty($reshook)) else { $desc = dol_htmlentitiesbr($lines[$i]->desc); } + + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; + + // View third's localtaxes for now + $localtax1_tx = get_localtax($txtva, 1, $object->thirdparty); + $localtax2_tx = get_localtax($txtva, 2, $object->thirdparty); $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, + $txtva, + $localtax1_tx, + $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->date_start, diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index aa15fbea86b..85c9d0d158f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -612,7 +612,7 @@ class Contrat extends CommonObject // Selectionne les lignes contrats liees a un produit $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; - $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; + $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; $sql.= " d.total_ht,"; $sql.= " d.total_tva,"; $sql.= " d.total_localtax1,"; @@ -646,9 +646,12 @@ class Contrat extends CommonObject $line->fk_contrat = $objp->fk_contrat; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; + $line->vat_src_code q= $objp->vat_src_code ; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; $line->statut = $objp->statut; $line->remise_percent = $objp->remise_percent; @@ -2715,6 +2718,7 @@ class ContratLigne extends CommonObjectLine $this->statut=(int) $this->statut; $this->label=trim($this->label); $this->description=trim($this->description); + $this->vat_src_code=trim($this->vat_src_code); $this->tva_tx=trim($this->tva_tx); $this->localtax1_tx=trim($this->localtax1_tx); $this->localtax2_tx=trim($this->localtax2_tx); @@ -2786,6 +2790,7 @@ class ContratLigne extends CommonObjectLine $sql.= " date_ouverture=".($this->date_ouverture!=''?"'".$this->db->idate($this->date_ouverture)."'":"null").","; $sql.= " date_fin_validite=".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null").","; $sql.= " date_cloture=".($this->date_cloture!=''?"'".$this->db->idate($this->date_cloture)."'":"null").","; + $sql.= " vat_src_code='".$this->vat_src_code."',"; $sql.= " tva_tx='".$this->tva_tx."',"; $sql.= " localtax1_tx='".$this->localtax1_tx."',"; $sql.= " localtax2_tx='".$this->localtax2_tx."',"; @@ -2914,6 +2919,7 @@ class ContratLigne extends CommonObjectLine $sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',"; $sql.= ($this->fk_product>0 ? $this->fk_product : "null").","; $sql.= " '".$this->qty."',"; + $sql.= " '".$this->vat_src_code."',"; $sql.= " '".$this->tva_tx."',"; $sql.= " '".$this->localtax1_tx."',"; $sql.= " '".$this->localtax2_tx."',"; From 29bede28f05a3004a55de6ad10b5001cae0cc92e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 4 May 2017 06:49:29 +0200 Subject: [PATCH 123/172] New : Accountancy - Add export model towards Agiris --- .../class/accountancyexport.class.php | 51 +++++++++++++++++-- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 524326e320c..b59d8ca51a6 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -47,6 +47,7 @@ class AccountancyExport public static $EXPORT_TYPE_QUADRATUS = 6; public static $EXPORT_TYPE_EBP = 7; public static $EXPORT_TYPE_COGILOG = 8; + public static $EXPORT_TYPE_AGIRIS = 9; /** * @@ -96,6 +97,7 @@ class AccountancyExport self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), + self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris') ); } @@ -145,6 +147,9 @@ class AccountancyExport case self::$EXPORT_TYPE_COGILOG : $this->exportCogilog($TData); break; + case self::$EXPORT_TYPE_AGIRIS : + $this->exportAgiris($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -382,7 +387,7 @@ class AccountancyExport /** - * Export format : Normal + * Export format : EBP * * @param array $objectLines data * @@ -401,8 +406,7 @@ class AccountancyExport print $line->code_journal . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator; - print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; - print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; + print substr(length_accounta($line->code_tiers),0,2) . $this->separator; print price2num($line->montant).$this->separator; print $line->sens.$this->separator; print $date . $this->separator; @@ -412,6 +416,47 @@ class AccountancyExport } + /** + * Export format : Agiris + * + * @param array $objectLines data + * + * @return void + */ + public function exportAgiris($objectLines) { + + $this->separator = ';'; + + foreach ( $objectLines as $line ) { + + $date = dol_print_date($line->doc_date, '%d%m%Y'); + + print $line->id . $this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; + print $date . $this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; + + if (empty($line->code_tiers)) { + print length_accountg($line->numero_compte) . $this->separator; + } else { + if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') { + print '411' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + } + if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') { + print '401' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + } + } + + print length_accounta($line->code_tiers) . $this->separator; + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print price($line->montant).$this->separator; + print $line->sens.$this->separator; + print $line->code_journal . $this->separator; + print $this->end_line; + } + } + /** * diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index bd1e41c5464..e84f85898c8 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -225,6 +225,7 @@ Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution Modelcsv_quadratus=Export towards Quadratus QuadraCompta Modelcsv_ebp=Export towards EBP Modelcsv_cogilog=Export towards Cogilog +Modelcsv_agiris=Export towards Agiris (Test) ChartofaccountsId=Chart of accounts Id ## Tools - Init accounting account on product / service From 76f2cc3f1e3a3e4bef4831ca9b76d331664ea0e2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 4 May 2017 06:52:07 +0200 Subject: [PATCH 124/172] False operation --- htdocs/accountancy/class/accountancyexport.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index b59d8ca51a6..1af9e5d1a6b 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -406,7 +406,8 @@ class AccountancyExport print $line->code_journal . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator; - print substr(length_accounta($line->code_tiers),0,2) . $this->separator; + print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print price2num($line->montant).$this->separator; print $line->sens.$this->separator; print $date . $this->separator; From 85bf4b742b15ca267431530cb8eb3ab932002d18 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Thu, 4 May 2017 17:21:59 +1100 Subject: [PATCH 125/172] Fix typo --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 85c9d0d158f..3187fcaba42 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -646,7 +646,7 @@ class Contrat extends CommonObject $line->fk_contrat = $objp->fk_contrat; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; - $line->vat_src_code q= $objp->vat_src_code ; + $line->vat_src_code = $objp->vat_src_code ; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; From 694efca32ac10f666b59b57b7a53d48e20ba0e4c Mon Sep 17 00:00:00 2001 From: "Guillaume T. (Arck Consulting)" Date: Thu, 4 May 2017 09:32:06 +0200 Subject: [PATCH 126/172] [FIX] Credit Note for fourn doesn't work, missing filed in create method & attribut --- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 42daafe9c2d..1798eb19059 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -128,7 +128,9 @@ class FactureFournisseur extends CommonInvoice public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; - + //! id of source invoice if replacement invoice or credit note + public $fk_facture_source; + /** * Standard invoice */ @@ -263,6 +265,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; + $sql.= ", fk_facture_source"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -286,6 +289,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(isset($this->fk_facture_source)?$this->fk_facture_source:"NULL"); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From 270c3db32ebc861d6714321465a5379f4f6d71d0 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Apr 2017 16:47:06 +0200 Subject: [PATCH 127/172] fix params order for tha addline() function please check to last param "$request_data->fk_remise_except", I couldn't find a corresponding parameter name in the addline() function --- htdocs/comm/propal/class/api_proposals.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 0440793ceac..ec7ca53357a 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -260,12 +260,9 @@ class Proposals extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, 'HT', 0, - $request_data->date_start, - $request_data->date_end, + $request_data->info_bits, $request_data->product_type, $request_data->rang, $request_data->special_code, @@ -273,10 +270,14 @@ class Proposals extends DolibarrApi $request_data->fk_fournprice, $request_data->pa_ht, $request_data->label, + $request_data->date_start, + $request_data->date_end, $request_data->array_options, $request_data->fk_unit, $this->element, $request_data->id + // not used anymore ? + // $request_data->fk_remise_except ); if ($updateRes > 0) { From 8318ebc1096d464b6427d0812c6d32c79265b233 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 10:45:20 +0200 Subject: [PATCH 128/172] Fix missing field into addline of proposals --- htdocs/comm/propal/class/api_proposals.class.php | 11 ++++++----- htdocs/comm/propal/class/propal.class.php | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index ec7ca53357a..fd508b03256 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -16,9 +16,10 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; /** * API class for orders @@ -275,9 +276,9 @@ class Proposals extends DolibarrApi $request_data->array_options, $request_data->fk_unit, $this->element, - $request_data->id - // not used anymore ? - // $request_data->fk_remise_except + $request_data->id, + $request_data->pu_ht_devise, + $request_data->fk_remise_except ); if ($updateRes > 0) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 4587e960c4c..a18dbfb86b0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -395,15 +395,16 @@ class Propal extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $origin 'order', ... * @param int $origin_id Id of origin object - * @return int >0 if OK, <0 if KO * @param double $pu_ht_devise Unit price in currency + * @param int $fk_remise_except Id discount if line is from a discount + * @return int >0 if OK, <0 if KO * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise=0, $fk_remise_except=0) { global $mysoc, $conf, $langs; - dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); + dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -519,6 +520,8 @@ class Propal extends CommonObject $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->fk_product=$fk_product; + $this->line->product_type=$type; + $this->line->fk_remise_except=$fk_remise_except; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; $this->line->rang=$rangtouse; @@ -528,7 +531,6 @@ class Propal extends CommonObject $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc=$total_ttc; - $this->line->product_type=$type; $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; $this->line->fk_unit=$fk_unit; From f543461e9b084de70e84ba06a5ed15c4f2943394 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 11:21:28 +0200 Subject: [PATCH 129/172] Complete the substitution array with substitution array with all possible keys --- htdocs/core/class/html.formmail.class.php | 3 +++ htdocs/core/lib/functions.lib.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d7ab17e60c4..6c411b60e66 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1133,6 +1133,9 @@ class FormMail extends Form $vars['__SECUREKEYPAYPAL_MEMBER__']=''; } } + + $vars=complete_substitutions_array($vars, $langs, null, null); + return $vars; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 857ddc6eec2..b6cf92aa81d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4953,7 +4953,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) } /** - * Complete the $substitutionarray with more entries + * Complete the $substitutionarray with more entries. + * Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called. * * @param array $substitutionarray Array substitution old value => new value value * @param Translate $outputlangs Output language From 7ec46b3bd6ace90a7e91e51198d874f484ff1e0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 12:35:45 +0200 Subject: [PATCH 130/172] Finished work to have substitution keys code mutualized. --- htdocs/accountancy/admin/accountmodel.php | 3 +-- htdocs/admin/mails_templates.php | 22 +++++++++++++++------- htdocs/core/class/html.formmail.class.php | 18 ++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 0b4aa70e548..55c194cd416 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -757,8 +757,7 @@ if ($id) { print '* '.$langs->trans("AvailableVariables").": "; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail=new FormMail($db); - $tmp=$formmail->getAvailableSubstitKey('form'); + $tmp=FormMail::getAvailableSubstitKey('formemail'); print implode(', ', $tmp); print ''; } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index f0bf5609adf..08ba76dca99 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -118,17 +118,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail=new FormMail($db); if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $tmp=$formmail->getAvailableSubstitKey('form'); + $tmp=FormMail::getAvailableSubstitKey('formemail'); $tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; $helpsubstit = $langs->trans("AvailableVariables").':
    '.implode('
    ', $tmp); $helpsubstitforlines = $langs->trans("AvailableVariables").':
    '.implode('
    ', $tmp); } else { - $tmp=$formmail->getAvailableSubstitKey('formwithlines'); + $tmp=FormMail::getAvailableSubstitKey('formemailwithlines'); $tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; $helpsubstit = $langs->trans("AvailableVariables").':
    '.implode('
    ', $tmp); - $tmp=$formmail->getAvailableSubstitKey('formforlines'); + $tmp=FormMail::getAvailableSubstitKey('formemailforlines'); $helpsubstitforlines = $langs->trans("AvailableVariables").':
    '.implode('
    ', $tmp); } @@ -484,7 +484,11 @@ if ($action != 'edit') { print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; - else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); + else if (! empty($tabhelp[$id][$value])) + { + if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click + else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover + } else print $valuetoshow; print ''; } @@ -539,8 +543,8 @@ if ($action != 'edit') foreach ($fieldsforcontent as $tmpfieldlist) { print ''; - if ($tmpfieldlist == 'content') print ''.$form->textwithpicto($langs->trans("Content"),$tabhelp[$id][$tmpfieldlist]).'
    '; - if ($tmpfieldlist == 'content_lines') print ''.$form->textwithpicto($langs->trans("ContentForLines"),$tabhelp[$id][$tmpfieldlist]).'
    '; + if ($tmpfieldlist == 'content') print ''.$form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
    '; + if ($tmpfieldlist == 'content_lines') print ''.$form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
    '; if ($context != 'hide') { @@ -624,7 +628,11 @@ if ($resql) // Affiche nom du champ if ($showfield) { - if (! empty($tabhelp[$id][$value])) $valuetoshow = $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); + if (! empty($tabhelp[$id][$value])) + { + if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover + else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover + } print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6c411b60e66..6988fb4b992 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1059,18 +1059,18 @@ class FormMail extends Form } /** - * Set substit array from object + * Get list of substition keys available. * - * @param string $mode 'form', 'formwithlines', 'formforlines' or 'emailing' + * @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ... * @return void */ - function getAvailableSubstitKey($mode='form') + static function getAvailableSubstitKey($mode='formemail') { - global $conf; + global $conf, $langs; $vars=array(); - if ($mode == 'form' || $mode == 'formwithlines' || $mode == 'formforlines') + if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { $vars=array( '__REF__', @@ -1134,7 +1134,13 @@ class FormMail extends Form } } - $vars=complete_substitutions_array($vars, $langs, null, null); + $tmparray=array(); + $parameters=array('mode'=>$mode); + complete_substitutions_array($tmparray, $langs, null, $parameters); + foreach($tmparray as $key => $val) + { + $vars[]=$key; + } return $vars; } From 1a6c118a5dfa001a8dd5cda90402d543cd067902 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 12:41:29 +0200 Subject: [PATCH 131/172] Fix travis warning --- htdocs/product/inventory/card.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index dc279cc0929..827354b864c 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -127,8 +127,6 @@ if (empty($reshook)) header('Location: '.dol_buildpath('/product/inventory/card.php?action=create', 1)); exit; } - - break; } switch($action) { From 7d5b5cf86a1da58fad3a006cdee9f2ec079d2eb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 13:09:42 +0200 Subject: [PATCH 132/172] Better behavior for tooltip on click --- htdocs/core/class/html.form.class.php | 5 +++-- htdocs/langs/en_US/main.lang | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3275ee0f303..cab420fe888 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -492,10 +492,11 @@ class Form */ function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='') { - global $conf; + global $conf, $langs; $alt = ''; - + if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp"); + //For backwards compatibility if ($type == '0') $type = 'info'; elseif ($type == '1') $type = 'help'; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1a3eea413df..c567890730a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -766,6 +766,9 @@ Download=Download ActualizeCurrency=Update currency rate Fiscalyear=Fiscal year ModuleBuilder=Module Builder +SetMultiCurrencyCode=Set currency +BulkActions=Bulk actions +ClickToShowHelp=Click to show tooltip help # Week day Monday=Monday Tuesday=Tuesday @@ -822,6 +825,4 @@ SearchIntoInterventions=Interventions SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports -SearchIntoLeaves=Leaves -SetMultiCurrencyCode=Set currency -BulkActions=Bulk actions \ No newline at end of file +SearchIntoLeaves=Leaves \ No newline at end of file From 0c76db7973ef2f410f08a4551e36bff48720b5dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 13:41:37 +0200 Subject: [PATCH 133/172] FIX #6698 #6742 --- htdocs/comm/mailing/cibles.php | 51 +++++++++++--------- htdocs/comm/mailing/class/mailing.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/class/html.formmailing.class.php | 14 +++--- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d3642c50393..118cc336fb7 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -161,6 +161,7 @@ if ($_POST["button_removefilter"]) $search_lastname=''; $search_firstname=''; $search_email=''; + $search_dest_status=''; } @@ -399,7 +400,7 @@ if ($object->fetch($id) >= 0) if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'"; if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'"; if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'"; - if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; + if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield,$sortorder); // Count total nb of records @@ -411,7 +412,7 @@ if ($object->fetch($id) >= 0) } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets $sql .= $db->plimit($limit+1, $offset); - + $resql=$db->query($sql); if ($resql) { @@ -446,29 +447,12 @@ if ($object->fetch($id) >= 0) print ''; - if ($page) $param.= "&page=".$page; + if ($page) $param.= "&page=".$page; + print ''; - print ''; - print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.firstname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder); - // Date sending - if ($object->statut < 2) - { - print_liste_field_titre(''); - } - else - { - print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$param,'','align="center"',$sortfield,$sortorder); - } - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - print ''; - + // Ligne des champs de filtres - print ''; + print ''; // EMail print ''; - + // Date sending print ''; print ''; + + print ''; + print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.lastname",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.firstname",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder); + // Date sending + if ($object->statut < 2) + { + print_liste_field_titre(''); + } + else + { + print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$param,'','align="center"',$sortfield,$sortorder); + } + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print ''; $i = 0; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index b0dff81332c..43a3cdcb78d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -80,8 +80,8 @@ class Mailing extends CommonObject $this->statuts[2] = 'MailingStatusSentPartialy'; $this->statuts[3] = 'MailingStatusSentCompletely'; - $this->statut_dest[0] = 'MailingStatusNotSent'; $this->statut_dest[-1] = 'MailingStatusError'; + $this->statut_dest[0] = 'MailingStatusNotSent'; $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6988fb4b992..ab58854f2c4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1139,7 +1139,7 @@ class FormMail extends Form complete_substitutions_array($tmparray, $langs, null, $parameters); foreach($tmparray as $key => $val) { - $vars[]=$key; + $vars[$key]=$key; } return $vars; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 0c63049f9d8..9fb4e4eea86 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -32,9 +32,9 @@ class FormMailing extends Form /** * Output a select with destinaries status * - * @param string $selectedid the selected id - * @param string $htmlname name of controm - * @param integer $show_empty show empty option + * @param string $selectedid The selected id + * @param string $htmlname Name of controm + * @param integer $show_empty Show empty option * @return string HTML select */ public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) { @@ -46,13 +46,13 @@ class FormMailing extends Form $mailing = new Mailing($this->db); $options = array(); - + if ($show_empty) { - $options[''] = ''; + $options[-2] = ''; // Note -1 is used for error } - $options = array_merge($options, $mailing->statut_dest); + $options = $options + $mailing->statut_dest; - return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); + return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); } } From ea58fb0b50b947e623abc439cb0fb93c4f8f4c7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 15:52:12 +0200 Subject: [PATCH 134/172] Fix triggered error --- .../class/fournisseur.commande.class.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 04f50e9fbcb..fb43b68de95 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2669,21 +2669,22 @@ class CommandeFournisseur extends CommonOrder $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method'; $sql.= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id); - $query = $db->query($sql); - if ($query && $db->num_rows($query)) + $resql = $db->query($sql); + if ($resql) { - $obj = $db->fetch_object($query); - - $string = $langs->trans($obj->code); - if ($string == $obj->code) + if ($db->num_rows($query)) { - $string = $obj->label != '-' ? $obj->label : ''; - } - - return $string; + $obj = $db->fetch_object($query); + + $string = $langs->trans($obj->code); + if ($string == $obj->code) + { + $string = $obj->label != '-' ? $obj->label : ''; + } + return $string; + } } - - dol_print_error($db); + else dol_print_error($db); } return ''; From ce05c74e47859f0ec78d3a3c616d4a0b7784d738 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 17:48:52 +0200 Subject: [PATCH 135/172] NEW SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT --- .../class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/dispatch.php | 37 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fb43b68de95..c326d033de8 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2818,7 +2818,7 @@ class CommandeFournisseur extends CommonOrder /** - * Calc status regarding dispatch stock + * Calc status regarding to dispatched stock * * @param User $user User action * @param int $closeopenorder Close if received diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c87b3a62bed..b7e3830ad5c 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -467,16 +467,14 @@ if ($id > 0 || ! empty($ref)) { if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { $nbproduct++; - $var = ! $var; - // To show detail cref and description value, we must make calculation by cref // print ($objp->cref?' ('.$objp->cref.')':''); // if ($objp->description) print '
    '.nl2br($objp->description); $suffix = '_0_' . $i; print "\n"; - print '' . "\n"; - print "
    "; + print '' . "\n"; + print ''; $linktoprod = '' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . ''; $linktoprod .= ' - ' . $objp->label . "\n"; @@ -500,7 +498,7 @@ if ($id > 0 || ! empty($ref)) { print ""; } - $var = ! $var; + // Define unit price for PMP calculation $up_ht_disc = $objp->subprice; if (! empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU'); @@ -517,11 +515,21 @@ if ($id > 0 || ! empty($ref)) { print ''; // Warehouse column print ''; - print ''; + print ''; print ''; // Dispatch column print ''; print ''; - print ''; + + print ''; print '\n'; + print ''."\n"; print "\n"; From a1e92467947074c5feef8d2199b6177be4c7cb4b Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Fri, 5 May 2017 10:34:38 +1100 Subject: [PATCH 142/172] Resolved merge conflict [2] --- htdocs/comm/propal/class/propal.class.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3df1c82b4ad..7b05adf1fb6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3626,11 +3626,7 @@ class PropaleLigne extends CommonObjectLine $this->qty = $objp->qty; $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; -<<<<<<< HEAD - $this->vat_src_code = $objp->vat_src_code; -======= $this->vat_src_code = $objp->vat_src_code; ->>>>>>> upstream/5.0 $this->tva_tx = $objp->tva_tx; $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; From f32d19fb73abdbe2cfed02ef37af34dc473eca6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 09:15:14 +0200 Subject: [PATCH 143/172] FIX #6767 serious critical error no login possible --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 1 + htdocs/install/mysql/tables/llx_events.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 81191e7a84e..afda09aa785 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -262,3 +262,4 @@ ALTER TABLE llx_product_price ALTER COLUMN date_price SET DEFAULT NULL; ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx; ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx; +ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); diff --git a/htdocs/install/mysql/tables/llx_events.sql b/htdocs/install/mysql/tables/llx_events.sql index 29a369269c3..c153522cb09 100644 --- a/htdocs/install/mysql/tables/llx_events.sql +++ b/htdocs/install/mysql/tables/llx_events.sql @@ -30,7 +30,7 @@ create table llx_events dateevent datetime, -- date event fk_user integer, -- id user description varchar(250) NOT NULL, -- full description of action - ip varchar(32) NOT NULL, -- ip + ip varchar(250) NOT NULL, -- ip (must contains ip v4 and v6 or dns names) user_agent varchar(255) NULL, -- user agent fk_object integer -- id of related object ) ENGINE=innodb; From f069ef98445e651a37487ae900730a5b2b550c20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 20:40:13 +0200 Subject: [PATCH 144/172] FIX #6767 --- htdocs/admin/expensereport.php | 2 +- htdocs/admin/expensereport_extrafields.php | 2 +- htdocs/core/lib/pdf.lib.php | 9 ++++++++- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/langs/en_US/admin.lang | 3 +++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index dad17585e2e..b8626827595 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -230,7 +230,7 @@ print load_fiche_titre($langs->trans("ExpenseReportsSetup"),$linkback,'title_set $head=expensereport_admin_prepare_head(); -dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), 0, 'trip'); +dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), -1, 'trip'); // Interventions numbering model /* diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 65e1592eff8..d1d3aacc9cc 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -74,7 +74,7 @@ print load_fiche_titre($langs->trans("ExpenseReportsSetup"),$linkback,'title_set $head = expensereport_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("ExpenseReports"), 0, 'trip'); +dol_fiche_head($head, 'attributes', $langs->trans("ExpenseReports"), -1, 'trip'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2fc447daffd..e83faee6c8d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -599,7 +599,14 @@ function pdf_getSubstitutionArray($outputlangs) $substitutionarray=array( '__MYCOMPANY_NAME__' => $mysoc->name, '__MYCOMPANY_EMAIL__' => $mysoc->email, - '__USER_ID__' => $user->id, + '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, + '__MYCOMPANY_PROFID2__' => $mysoc->idprof2, + '__MYCOMPANY_PROFID3__' => $mysoc->idprof3, + '__MYCOMPANY_PROFID4__' => $mysoc->idprof4, + '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, + '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, + '__MYCOMPANY_CAPITAL__' => $mysoc->capital, + '__USER_ID__' => $user->id, '__USER_LOGIN__' => $user->login, '__USER_LASTNAME__' => $user->lastname, '__USER_FIRSTNAME__' => $user->firstname, diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 1982ef6aff8..a6666d37ee0 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -248,3 +248,6 @@ insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); + +ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 35037387c1f..1356a980164 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -434,6 +434,9 @@ PageUrlForDefaultValuesList=
    For page that list thirdparties, it is % GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field +ProductDocumentTemplates=Document templates to generate product document +FreeLegalTextOnExpenseReports=Free legal text on expense reports +WatermarkOnDraftExpenseReports=Watermark on draft expense reports # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management From ef0d395a1a536fb75f8acdcfdbf8c04ce54086a4 Mon Sep 17 00:00:00 2001 From: "Guillaume T. (Arck Consulting)" Date: Thu, 4 May 2017 09:32:06 +0200 Subject: [PATCH 145/172] [FIX] Credit Note for fourn doesn't work, missing filed in create method & attribut --- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 42daafe9c2d..1798eb19059 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -128,7 +128,9 @@ class FactureFournisseur extends CommonInvoice public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; - + //! id of source invoice if replacement invoice or credit note + public $fk_facture_source; + /** * Standard invoice */ @@ -263,6 +265,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; + $sql.= ", fk_facture_source"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -286,6 +289,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(isset($this->fk_facture_source)?$this->fk_facture_source:"NULL"); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From 9785e9b2988529c3e8bd626828866a7dd1194ce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 09:57:51 +0200 Subject: [PATCH 146/172] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2e8f75f796..4b6c1263026 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2963,20 +2963,20 @@ abstract class CommonObject foreach ($this->lines as $line) { - $totalOrdered+=$line->qty_asked ?: 0; // defined for shipment only - $totalToShip+= $line->qty_shipped ?: 0; // defined for shipment only + $totalOrdered+=($line->qty_asked ? $line->qty_asked : 0); // defined for shipment only + $totalToShip+=($line->qty_shipped ? $line->qty_shipped : 0); // defined for shipment only // Define qty, weight, volume, weight_units, volume_units if ($this->element == 'shipping') { // for shipments - $qty = $line->qty_shipped ?: 0; + $qty = $line->qty_shipped ? $line->qty_shipped : 0; } else { - $qty = $line->qty ?: 0; + $qty = $line->qty ? $line->qty : 0; } - $weight = $line->weight ?: 0; - $volume = $line->volume ?: 0; + $weight = $line->weight ? $line->weight : 0; + $volume = $line->volume ? $line->volume : 0; $weight_units=$line->weight_units; $volume_units=$line->volume_units; From 68b63927e0cdfafd6df75cd92008de89c88eb9c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 12:33:49 +0200 Subject: [PATCH 147/172] Maxi miscellaneous debug --- htdocs/admin/supplier_invoice.php | 2 +- htdocs/admin/supplier_order.php | 2 +- htdocs/admin/supplier_payment.php | 24 +- htdocs/admin/supplierinvoice_extrafields.php | 2 +- .../admin/supplierinvoicedet_extrafields.php | 2 +- htdocs/admin/supplierorder_extrafields.php | 2 +- htdocs/admin/supplierorderdet_extrafields.php | 2 +- htdocs/categories/index.php | 8 +- htdocs/compta/paiement/cheque/card.php | 225 +++++++++--------- htdocs/compta/paiement/cheque/index.php | 14 +- htdocs/core/lib/files.lib.php | 14 +- htdocs/core/lib/functions.lib.php | 26 +- .../supplier_payment/{pdf => doc}/index.html | 0 .../pdf_standard.modules.php} | 10 +- htdocs/fourn/facture/card.php | 55 +---- htdocs/fourn/facture/contact.php | 2 +- htdocs/fourn/facture/document.php | 4 +- htdocs/fourn/facture/info.php | 2 +- htdocs/fourn/facture/note.php | 9 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/supplier_proposal/card.php | 11 +- .../class/supplier_proposal.class.php | 6 +- 22 files changed, 203 insertions(+), 220 deletions(-) rename htdocs/core/modules/supplier_payment/{pdf => doc}/index.html (100%) rename htdocs/core/modules/supplier_payment/{pdf/pdf_cow.modules.php => doc/pdf_standard.modules.php} (98%) diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index dd8210611e9..de128184d18 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -205,7 +205,7 @@ print "
    "; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'invoice', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'invoice', $langs->trans("Suppliers"), -1, 'company'); // Supplier invoice numbering module diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index a170f7ccd37..030a507ce20 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -234,7 +234,7 @@ print "
    "; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'order', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'order', $langs->trans("Suppliers"), -1, 'company'); // Supplier order numbering module diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 0f6cbff6179..adaa114b1ca 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -65,7 +65,7 @@ if ($action == 'updateMask') } }else if ($action == 'setmod') { - dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } // define constants for models generator that need parameters @@ -138,7 +138,7 @@ else if ($action == 'specimen') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); foreach($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/supplier_payment/pdf/pdf_".$modele.".modules.php",0); + $file=dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php",0); if (file_exists($file)) { $filefound=1; @@ -188,7 +188,7 @@ print load_fiche_titre($langs->trans("SupplierPaymentSetup"),$linkback,'title_se print "
    "; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), -1, 'company'); /* * Numbering module @@ -198,12 +198,6 @@ if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMEN print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', ''); -/* - * Document templates generators - */ -print '
    '; -print load_fiche_titre($langs->trans("BillsPDFModules"),'',''); - // Load array def with activated templates $def = array(); $sql = "SELECT nom"; @@ -349,6 +343,12 @@ foreach ($dirmodels as $reldir) print '
    '; print ''; @@ -489,7 +473,7 @@ if ($object->fetch($id) >= 0) print ''; print ' '; print ''; print ' '; @@ -504,6 +488,25 @@ if ($object->fetch($id) >= 0) print $searchpitco; print '
    '; print ''; print ''; - print ''; + + print ''; + if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! + { + print $langs->trans("BuyingPrice").': '; + } + else + { + print ''; + } + // hidden fields for js function print ''; print ''; @@ -544,11 +552,22 @@ if ($id > 0 || ! empty($ref)) { print '' . img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '
    '; print ''; print ''; - print ''; + + print ''; + if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! + { + print $langs->trans("BuyingPrice").': '; + } + else + { + print ''; + } + // hidden fields for js function print ''; print ''; From 2de335e2dc29194671f67eb4146bbdf3ba447e5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 18:49:58 +0200 Subject: [PATCH 136/172] Action must be a verb --- htdocs/langs/en_US/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 216c9187b0f..ec4e218a11e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -171,7 +171,7 @@ SearchOf=Search Valid=Valid Approve=Approve Disapprove=Disapprove -ReOpen=Re-Opened +ReOpen=Re-Open Upload=Send file ToLink=Link Select=Select From bf616cbe05437e89e4f9140e600ddd3593e61929 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 19:05:02 +0200 Subject: [PATCH 137/172] Fix bad var --- htdocs/core/class/conf.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 6bca5b7d5a4..28a287971a8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -358,8 +358,8 @@ class Conf $this->supplier_order->dir_temp=$rootfordata."/fournisseur/commande/temp"; $this->supplier_invoice=new stdClass(); $this->supplier_invoice->enabled=1; - $this->supplier_order->dir_output=$rootfordata."/fournisseur/facture"; - $this->supplier_order->dir_temp=$rootfordata."/fournisseur/facture/temp"; + $this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture"; + $this->supplier_invoice->dir_temp=$rootfordata."/fournisseur/facture/temp"; } } From 39d9a0f979c8163608120c7d668f57968a625aac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 19:11:19 +0200 Subject: [PATCH 138/172] Support of pdf preview on supplier orders --- htdocs/core/lib/files.lib.php | 10 ++++++++-- htdocs/core/lib/functions.lib.php | 23 +++++++++++------------ htdocs/theme/eldy/style.css.php | 3 +++ htdocs/theme/md/style.css.php | 6 ++---- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index cbf4af402ae..18f1e30edc7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1628,8 +1628,14 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu // Wrapping pour les apercu intervention elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) { - if ($fuser->rights->ficheinter->lire) $accessallowed=1; - $original_file=$conf->ficheinter->dir_output.'/'.$original_file; + if ($fuser->rights->ficheinter->lire) $accessallowed=1; + $original_file=$conf->ficheinter->dir_output.'/'.$original_file; + } + // Wrapping pour les apercu commande + elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) + { + if ($fuser->rights->fournisseur->commande->lire) $accessallowed=1; + $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; } // Wrapping pour les images des stats propales elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b6cf92aa81d..da0a33e7ef1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1065,11 +1065,11 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; $modulepart='unknown'; - if ($object->element == 'societe') $modulepart='societe'; - if ($object->element == 'contact') $modulepart='contact'; - if ($object->element == 'member') $modulepart='memberphoto'; - if ($object->element == 'user') $modulepart='userphoto'; - if ($object->element == 'product') $modulepart='product'; + if ($object->element == 'societe') $modulepart='societe'; + if ($object->element == 'contact') $modulepart='contact'; + if ($object->element == 'member') $modulepart='memberphoto'; + if ($object->element == 'user') $modulepart='userphoto'; + if ($object->element == 'product') $modulepart='product'; if (class_exists("Imagick")) { if ($object->element == 'propal') $modulepart='propal'; @@ -1077,6 +1077,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'facture') $modulepart='facture'; if ($object->element == 'fichinter') $modulepart='ficheinter'; if ($object->element == 'contrat') $modulepart='contract'; + if ($object->element == 'order_supplier') $modulepart='supplier_order'; } if ($object->element == 'product') @@ -1102,12 +1103,11 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { if ($showimage) { - if ($modulepart != 'unknown') + if ($modulepart != 'unknown') { $phototoshow=''; - // Check if a preview file is available - if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract')) && class_exists("Imagick")) + if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); $dir_output = $conf->$modulepart->dir_output . "/"; @@ -1137,7 +1137,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (file_exists($fileimage)) { $phototoshow = '
    '; - $phototoshow.= ''; + $phototoshow.= ''; $phototoshow.= '
    '; } // Si fichier png PDF de plus d'1 page trouve @@ -1145,7 +1145,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { $preview = preg_replace('/\.png/','',$relativepathimage) . "-0.png"; $phototoshow = '
    '; - $phototoshow.= '

    '; + $phototoshow.= '

    '; $phototoshow.= '

    '; } } @@ -1171,7 +1171,6 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $width=80; $cssclass='photorefcenter'; $nophoto=img_picto('', 'title_agenda', '', false, 1); - $morehtmlleft.='
    No photo
    '; } else { @@ -1179,8 +1178,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $picto = $object->picto; if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub $nophoto=img_picto('', 'object_'.$picto, '', false, 1); - $morehtmlleft.='
    No photo
    '; } + $morehtmlleft.='
    No photo
    '; $morehtmlleft.=''; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 41744ae0037..d0fae6d89a8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3002,6 +3002,9 @@ td.legendLabel { padding: 2px 2px 2px 0 !important; } margin-bottom: 2px; margin-top: 10px; } +.photowithborder { + border: 1px solid #f0f0f0; +} .photointooltip { margin-top: 6px; margin-bottom: 6px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 53e3ec0154c..48670ffb637 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3115,10 +3115,8 @@ td.legendLabel { padding: 2px 2px 2px 0 !important; } margin-bottom: 2px; margin-top: 2px; } -.photowithmargin { -/* -webkit-box-shadow: 0px 0px 3px #777; - -moz-box-shadow: 0px 0px 3px #777; - box-shadow: 0px 0px 3px #777;*/ +.photowithborder { + border: 1px solid #f0f0f0; } .photointoolitp { margin-top: 8px; From 768df56c07072c32daed2f9ae3cd918d01892968 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 20:16:55 +0200 Subject: [PATCH 139/172] Uniformize name of standard PDF template --- htdocs/admin/fichinter.php | 2 +- .../expedition/doc/pdf_rouget.modules.php | 2 +- .../fichinter/doc/pdf_soleil.modules.php | 2 +- htdocs/core/modules/modProduct.class.php | 11 +++++++++-- htdocs/core/modules/modService.class.php | 2 +- .../product/doc/pdf_standard.modules.php | 14 ++++---------- .../fichinter/admin/fichinter_extrafields.php | 2 +- .../admin/fichinterdet_extrafields.php | 2 +- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/sendings.lang | 1 - htdocs/product/admin/product.php | 3 --- htdocs/product/class/product.class.php | 19 ++++++++++++++++++- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 0b01f56857e..2b9dee321a6 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -265,7 +265,7 @@ print load_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'title_setu $head=fichinter_admin_prepare_head(); -dol_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), 0, 'intervention'); +dol_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), -1, 'intervention'); // Interventions numbering model diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d1697b767bd..3f7a73a650c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -49,7 +49,7 @@ class pdf_rouget extends ModelePdfExpedition $this->db = $db; $this->name = "rouget"; - $this->description = $langs->trans("DocumentModelSimple"); + $this->description = $langs->trans("DocumentModelStandardPDF"); $this->type = 'pdf'; $formatarray=pdf_getFormat(); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 83306b95adb..4d889f84902 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -65,7 +65,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->db = $db; $this->name = 'soleil'; - $this->description = $langs->trans("DocumentModelStandard"); + $this->description = $langs->trans("DocumentModelStandardPDF"); // Dimension page pour format A4 $this->type = 'pdf'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b2349ab77a0..30e64b5de2c 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -53,7 +53,7 @@ class modProduct extends DolibarrModules $this->module_position = 20; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Gestion des produits"; + $this->description = "Product management"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; @@ -83,7 +83,14 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; - + + /*$this->const[$r][0] = "PRODUCT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "standard"; + $this->const[$r][3] = 'Default module for document generation'; + $this->const[$r][4] = 0; + $r++;*/ + // Boxes $this->boxes = array( 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 7a5db7fcffd..c385ece4b26 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -51,7 +51,7 @@ class modService extends DolibarrModules $this->module_position = 30; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Gestion des services"; + $this->description = "Service management"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 5dca2b8378e..29df1127242 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -92,8 +92,8 @@ class pdf_standard extends ModelePDFProduct $langs->load("companies"); $this->db = $db; - $this->name = "PDF template"; - $this->description = $langs->trans("DocumentModelPdf"); + $this->name = "standard"; + $this->description = $langs->trans("DocumentModelStandardPDF"); // Dimension page pour format A4 $this->type = 'pdf'; @@ -107,15 +107,9 @@ class pdf_standard extends ModelePDFProduct $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_freetext = 0; // Support add of a personalised text // Recupere emetteur $this->emetteur=$mysoc; @@ -262,7 +256,7 @@ class pdf_standard extends ModelePDFProduct } if ($object->weight) { - $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.$object->length.'x'.$object->width.'x'.$object->height, 0, 1); + $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").': '.($object->length != ''?$object->length:'?').' x '.($object->width != ''?$object->width:'?').' x '.($object->height != ''?$object->height:'?'), 0, 1); $nexY = $pdf->GetY(); } if ($object->surface) diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index b7b809d277d..bab7572e60a 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -71,7 +71,7 @@ print load_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'title_setu $head=fichinter_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Interventions"), 0, 'intervention'); +dol_fiche_head($head, 'attributes', $langs->trans("Interventions"), -1, 'intervention'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index 776229a4c29..5fadc3f4c2c 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -72,7 +72,7 @@ print load_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'title_setu $head=fichinter_admin_prepare_head(); -dol_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), 0, 'intervention'); +dol_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), -1, 'intervention'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c567890730a..bc7c864b279 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -647,6 +647,7 @@ FreeLineOfType=Free entry of type CloneMainAttributes=Clone object with its main attributes PDFMerge=PDF Merge Merge=Merge +DocumentModelStandardPDF=Standard PDF template PrintContentArea=Show page to print main content area MenuManager=Menu manager WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only login %s is allowed to use application at the moment. diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index ac180cb5fe6..fcd28cc9f56 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -37,7 +37,6 @@ SendingSheet=Shipment sheet ConfirmDeleteSending=Are you sure you want to delete this shipment? ConfirmValidateSending=Are you sure you want to validate this shipment with reference %s? ConfirmCancelSending=Are you sure you want to cancel this shipment? -DocumentModelSimple=Simple document model DocumentModelMerou=Merou A5 model WarningNoQtyLeftToSend=Warning, no products waiting to be shipped. StatsOnShipmentsOnlyValidated=Statistics conducted on shipments only validated. Date used is date of validation of shipment (planed delivery date is not always known). diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 3582f8b25b6..5183eeb3382 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -512,10 +512,7 @@ foreach ($dirmodels as $reldir) } $htmltooltip.='

    '.$langs->trans("FeaturesSupported").':'; $htmltooltip.='
    '.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - $htmltooltip.='
    '.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); - $htmltooltip.='
    '.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); $htmltooltip.='
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); - $htmltooltip.='
    '.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); print '
    '; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e25ad186369..76a609e0a44 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4367,14 +4367,31 @@ class Product extends CommonObject $this->id=0; $this->ref = 'PRODUCT_SPEC'; $this->label = 'PRODUCT SPECIMEN'; - $this->description = 'PRODUCT SPECIMEN '.dol_print_date($now,'dayhourlog'); + $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now,'dayhourlog').'.'; $this->specimen=1; $this->country_id=1; $this->tosell=1; $this->tobuy=1; $this->tobatch=0; $this->note='This is a comment (private)'; + $this->date_creation = $now; + $this->date_modification = $now; + + $this->weight = 4; + $this->weight_unit = 1; + $this->length = 5; + $this->length_unit = 1; + $this->width = 6; + $this->width_unit = 0; + $this->height = null; + $this->height_unit = null; + + $this->surface = 30; + $this->surface_unit = 0; + $this->volume = 300; + $this->volume_unit = 0; + $this->barcode=-1; // Create barcode automatically } From 626c0d6d5e9308656777a9ff300dba88f0a3a054 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 20:40:13 +0200 Subject: [PATCH 140/172] Add more substitution keys for PDFs. --- htdocs/admin/expensereport.php | 2 +- htdocs/admin/expensereport_extrafields.php | 2 +- htdocs/core/lib/pdf.lib.php | 9 ++++++++- htdocs/langs/en_US/admin.lang | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index dad17585e2e..b8626827595 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -230,7 +230,7 @@ print load_fiche_titre($langs->trans("ExpenseReportsSetup"),$linkback,'title_set $head=expensereport_admin_prepare_head(); -dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), 0, 'trip'); +dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), -1, 'trip'); // Interventions numbering model /* diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 65e1592eff8..d1d3aacc9cc 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -74,7 +74,7 @@ print load_fiche_titre($langs->trans("ExpenseReportsSetup"),$linkback,'title_set $head = expensereport_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("ExpenseReports"), 0, 'trip'); +dol_fiche_head($head, 'attributes', $langs->trans("ExpenseReports"), -1, 'trip'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2fc447daffd..e83faee6c8d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -599,7 +599,14 @@ function pdf_getSubstitutionArray($outputlangs) $substitutionarray=array( '__MYCOMPANY_NAME__' => $mysoc->name, '__MYCOMPANY_EMAIL__' => $mysoc->email, - '__USER_ID__' => $user->id, + '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, + '__MYCOMPANY_PROFID2__' => $mysoc->idprof2, + '__MYCOMPANY_PROFID3__' => $mysoc->idprof3, + '__MYCOMPANY_PROFID4__' => $mysoc->idprof4, + '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, + '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, + '__MYCOMPANY_CAPITAL__' => $mysoc->capital, + '__USER_ID__' => $user->id, '__USER_LOGIN__' => $user->login, '__USER_LASTNAME__' => $user->lastname, '__USER_FIRSTNAME__' => $user->firstname, diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 35037387c1f..1356a980164 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -434,6 +434,9 @@ PageUrlForDefaultValuesList=
    For page that list thirdparties, it is % GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field +ProductDocumentTemplates=Document templates to generate product document +FreeLegalTextOnExpenseReports=Free legal text on expense reports +WatermarkOnDraftExpenseReports=Watermark on draft expense reports # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management From ffe4e4830454cba55fb558c5168e238b5460d44b Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Thu, 4 May 2017 21:37:27 +0200 Subject: [PATCH 141/172] Update agenda_other.php --- htdocs/admin/agenda_other.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 17ccd64d000..e70339b47c8 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -264,7 +264,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) require_once $dir.'/'.$file; $module = new $classname($db, new ActionComm($db)); - print '
    "; print (empty($module->name)?$name:$module->name); print "
    '; +/* + * Document templates generators + */ +print '
    '; +print load_fiche_titre($langs->trans("PaymentsPDFModules"),'',''); + print ''."\n"; print ''."\n"; print ''."\n"; @@ -363,7 +363,7 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_payment/pdf/"); + $dir = dol_buildpath($reldir."core/modules/supplier_payment/doc/"); if (is_dir($dir)) { @@ -440,8 +440,6 @@ foreach ($dirmodels as $reldir) $htmltooltip.='
    '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip.='

    '.$langs->trans("FeaturesSupported").':'; $htmltooltip.='
    '.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - $htmltooltip.='
    '.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); - $htmltooltip.='
    '.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); print ''; @@ -458,7 +456,7 @@ foreach ($dirmodels as $reldir) } } -print '
    '.$langs->trans("Name").''; print $form->textwithpicto('',$htmltooltip,1,0); print '

    '; +print ''; dol_fiche_end(); diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 701362e38f4..4e0bd1d0dd2 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -79,7 +79,7 @@ print "
    \n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index e741eb6cd75..26b3b42e970 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -79,7 +79,7 @@ print "
    \n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 00550995d19..bcad8121afc 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -75,7 +75,7 @@ print "
    \n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index f83ad1348fc..97d505144bb 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -76,7 +76,7 @@ print "
    \n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), 0, 'company'); +dol_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index d44407324c0..ca2b7b5c76f 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -125,7 +125,7 @@ if ($catname || $id > 0) print ''; print "\n"; print "\t\t"; - print $cat->description; + print dolGetFirstLineOfText($cat->description); print "\n"; print "\t\n"; } @@ -162,7 +162,7 @@ foreach($fulltree as $key => $val) 'rowid'=>$val['rowid'], 'fk_menu'=>$val['fk_parent'], 'entry'=>''. - ''. + //''. ''. '
    color?' style="background: #'.$categstatic->color.';"':' style="background: #aaa"').'>'.$li.''.dolGetFirstLineOfText($desc).''.dolGetFirstLineOfText($desc).''.img_view().'
    ' ); @@ -181,13 +181,13 @@ $nbofentries=(count($data) - 1); if ($nbofentries > 0) { - print ''; + print ''; tree_recur($data,$data[0],0); print ''; } else { - print ''; + print ''; print ''; print '\n"; $i=1; - $var=false; - while ($objp = $db->fetch_object($resql)) - { - $account_id = $objp->bid; - if (! isset($accounts[$objp->bid])) - $accounts[$objp->bid]=0; - $accounts[$objp->bid] += 1; - print ''; - print ''; - print ''; // Date operation - print ''; - print ''; - print ''; - print ''; - // Link to payment - print ''; - // Link to bank transaction - print ''; - // Action button - print ''; - print ''; - - $i++; - } + if ($num > 0) + { + while ($objp = $db->fetch_object($resql)) + { + $account_id = $objp->bid; + if (! isset($accounts[$objp->bid])) + $accounts[$objp->bid]=0; + $accounts[$objp->bid] += 1; + + print ''; + print ''; + print ''; // Date operation + print ''; + print ''; + print ''; + print ''; + // Link to payment + print ''; + // Link to bank transaction + print ''; + // Action button + print ''; + print ''; + + $i++; + } + } + else + { + print ''; + } + print "
    '.img_picto_common('','treemenu/branchbottom.gif').''; print $langs->trans("NoCategoryYet"); diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 625b2be518e..eed3a79335c 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -334,7 +334,7 @@ else // $head[$h][1] = $langs->trans("Info"); // $h++; - dol_fiche_head($head, $hselected, $langs->trans("Cheques"),0,'payment'); + dol_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); /* * Confirmation de la suppression du bordereau @@ -476,8 +476,7 @@ if ($action == 'new') print ''."\n"; print ''; - print '\n"; + print ''."\n"; print '\n"; print '\n"; print '\n"; @@ -487,59 +486,57 @@ if ($action == 'new') print ''; - print "\n"; - $var=true; - - foreach ($lines[$bid] as $lid => $value) + if (count($lines[$bid])) { - + foreach ($lines[$bid] as $lid => $value) + { + $account_id = $bid; + if (! isset($accounts[$bid])) + $accounts[$bid]=0; + $accounts[$bid] += 1; - $account_id = $bid; - if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1; + print ''; + print ''; + print '\n"; + print '\n"; + print '\n"; + print ''; - print ''; - print ''; - print '\n"; - print '\n"; - print '\n"; - print ''; - - // Link to payment - print ''; - // Link to bank transaction - print ''; - - print '' ; - print ''; - - $i++; + // Link to payment + print ''; + // Link to bank transaction + print ''; + + print '' ; + print ''; + + $i++; + } } print "
    '.$langs->trans("DateChequeReceived").' '; - print "'.$langs->trans("DateChequeReceived").''.$langs->trans("ChequeNumber")."'.$langs->trans("CheckTransmitter")."'.$langs->trans("Bank")."'.$langs->trans("Select")."
    "; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; print '
    '.dol_print_date($value["date"],'day').''.$value["numero"]."'.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'
    '.dol_print_date($value["date"],'day').''.$value["numero"]."'.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; - $paymentstatic->id=$value["paymentid"]; - $paymentstatic->ref=$value["paymentid"]; - if ($paymentstatic->id) - { - print $paymentstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - $accountlinestatic->rowid=$value["id"]; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - print ''; - print '
    '; + $paymentstatic->id=$value["paymentid"]; + $paymentstatic->ref=$value["paymentid"]; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + $accountlinestatic->rowid=$value["id"]; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + print ''; + print '
    "; print ''; @@ -686,65 +683,75 @@ else print_liste_field_titre(''); print "
    '.$i.''.dol_print_date($db->jdate($objp->date),'day').''.($objp->num_chq?$objp->num_chq:' ').''.dol_trunc($objp->emetteur,24).''.dol_trunc($objp->banque,24).''.price($objp->amount).''; - $paymentstatic->id=$objp->pid; - $paymentstatic->ref=$objp->pid; - if ($paymentstatic->id) - { - print $paymentstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - $accountlinestatic->rowid=$objp->rowid; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - if ($object->statut == 0) - { - print 'rowid.'">'.img_delete().''; - } - if ($object->statut == 1 && $objp->statut != 2) - { - print 'rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').''; - } - if ($objp->statut == 2) - { - print '   '.img_picto($langs->trans('CheckRejected'),'statut8').''; - } - print '
    '.$i.''.dol_print_date($db->jdate($objp->date),'day').''.($objp->num_chq?$objp->num_chq:' ').''.dol_trunc($objp->emetteur,24).''.dol_trunc($objp->banque,24).''.price($objp->amount).''; + $paymentstatic->id=$objp->pid; + $paymentstatic->ref=$objp->pid; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + $accountlinestatic->rowid=$objp->rowid; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + if ($object->statut == 0) + { + print 'rowid.'">'.img_delete().''; + } + if ($object->statut == 1 && $objp->statut != 2) + { + print 'rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').''; + } + if ($objp->statut == 2) + { + print '   '.img_picto($langs->trans('CheckRejected'),'statut8').''; + } + print '
    '; + print $langs->trans("None"); + print '
    "; print "
    "; } diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 2d77cb71061..97dc3c1674f 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -50,8 +50,6 @@ llxHeader('',$langs->trans("ChequesArea")); print load_fiche_titre($langs->trans("ChequesArea")); -//print ''; -//print '
    '; print '
    '; $sql = "SELECT count(b.rowid)"; @@ -90,7 +88,6 @@ else } -//print '
    '; print '
    '; $max=10; @@ -98,15 +95,13 @@ $max=10; $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref"; $sql.= ", bc.statut, bc.nbcheque"; $sql.= ", ba.label, ba.rowid as bid"; -$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE ba.rowid = bc.fk_bank_account"; $sql.= " AND bc.entity = ".$conf->entity; $sql.= " ORDER BY bc.date_bordereau DESC, rowid DESC"; $sql.= $db->plimit($max); $resql = $db->query($sql); - if ($resql) { print ''; @@ -128,9 +123,8 @@ if ($resql) $accountstatic->id=$objp->bid; $accountstatic->label=$objp->label; - - print "\n"; + print ''."\n"; print ''; print ''; @@ -142,15 +136,15 @@ if ($resql) print ''; } print "
    '.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db),'day').'
    "; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } -//print "
    \n"; print '
    '; llxFooter(); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 18f1e30edc7..8a85212a0ff 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1631,12 +1631,24 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu if ($fuser->rights->ficheinter->lire) $accessallowed=1; $original_file=$conf->ficheinter->dir_output.'/'.$original_file; } - // Wrapping pour les apercu commande + // Wrapping pour les apercu supplier proposal + elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) + { + if ($fuser->rights->supplier_proposal->lire) $accessallowed=1; + $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file; + } + // Wrapping pour les apercu supplier order elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { if ($fuser->rights->fournisseur->commande->lire) $accessallowed=1; $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; } + // Wrapping pour les apercu supplier invoice + elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) + { + if ($fuser->rights->fournisseur->facture->lire) $accessallowed=1; + $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; + } // Wrapping pour les images des stats propales elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index da0a33e7ef1..275bbae8c36 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1070,6 +1070,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'member') $modulepart='memberphoto'; if ($object->element == 'user') $modulepart='userphoto'; if ($object->element == 'product') $modulepart='product'; + if (class_exists("Imagick")) { if ($object->element == 'propal') $modulepart='propal'; @@ -1077,7 +1078,9 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'facture') $modulepart='facture'; if ($object->element == 'fichinter') $modulepart='ficheinter'; if ($object->element == 'contrat') $modulepart='contract'; - if ($object->element == 'order_supplier') $modulepart='supplier_order'; + if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; + if ($object->element == 'order_supplier') $modulepart='supplier_order'; + if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; } if ($object->element == 'product') @@ -1107,14 +1110,22 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { $phototoshow=''; // Check if a preview file is available - if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order')) && class_exists("Imagick")) + if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); $dir_output = $conf->$modulepart->dir_output . "/"; - $filepath = $dir_output . $objectref . "/"; + if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) + { + $subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; + } + else + { + $subdir = get_exdir($object->id, 0, 0, 0, $object, $modulepart).$objectref; + } + $filepath = $dir_output . $subdir . "/"; $file = $filepath . $objectref . ".pdf"; - $relativepath = $objectref.'/'.$objectref.'.pdf'; - + $relativepath = $subdir.'/'.$objectref.'.pdf'; + // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") $fileimage = $file.'_preview.png'; // If PDF has 1 page $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page @@ -4465,7 +4476,8 @@ function yn($yesno, $case=1, $color=0) /** * Return a path to have a directory according to object. - * New usage: $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart') + * New usage: $conf->module->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart') + * or: $conf->module->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart') if multidir_output not defined. * Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/" * * @param string $num Id of object (deprecated, $object will be used in future) @@ -4486,7 +4498,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; if (! empty($level) && in_array($modulepart, $arrayforoldpath)) { - // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided + // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); else $num = preg_replace('/^.*\-/i','',$num); $num = substr("000".$num, -$level); diff --git a/htdocs/core/modules/supplier_payment/pdf/index.html b/htdocs/core/modules/supplier_payment/doc/index.html similarity index 100% rename from htdocs/core/modules/supplier_payment/pdf/index.html rename to htdocs/core/modules/supplier_payment/doc/index.html diff --git a/htdocs/core/modules/supplier_payment/pdf/pdf_cow.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php similarity index 98% rename from htdocs/core/modules/supplier_payment/pdf/pdf_cow.modules.php rename to htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index edb37ddcdde..2b645e4a263 100644 --- a/htdocs/core/modules/supplier_payment/pdf/pdf_cow.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php'; /** * Class to generate the supplier invoices with the canelle model */ -class pdf_cow extends ModelePDFSuppliersPayments +class pdf_standard extends ModelePDFSuppliersPayments { var $db; var $name; @@ -70,8 +70,8 @@ class pdf_cow extends ModelePDFSuppliersPayments $langs->load("bills"); $this->db = $db; - $this->name = "cow"; - $this->description = $langs->trans('SuppliersPaymentModel'); + $this->name = "standard"; + $this->description = $langs->trans('DocumentModelStandardPDF'); // Dimension page pour format A4 $this->type = 'pdf'; @@ -85,10 +85,6 @@ class pdf_cow extends ModelePDFSuppliersPayments $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues $this->franchise=!$mysoc->tva_assuj; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 04af9470e6d..f930ad87979 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -70,7 +70,7 @@ $projectid = GETPOST('projectid','int'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); -//PDF +// PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -1194,32 +1194,11 @@ if (empty($reshook)) $trackid='sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - - // Build document - if ($action == 'builddoc') - { - // Save modele used - $object->fetch($id); - $object->fetch_thirdparty(); - - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - $outputlangs = $langs; - $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } + // Actions to build doc + $upload_dir = $conf->fournisseur->facture->dir_output; + $permissioncreate = $user->rights->fournisseur->facture->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Make calculation according to calculationrule if ($action == 'calculate') { @@ -1234,22 +1213,6 @@ if (empty($reshook)) exit; } } - // Delete file in doc form - if ($action == 'remove_file') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - if ($object->fetch($id)) - { - $object->fetch_thirdparty(); - $upload_dir = $conf->fournisseur->facture->dir_output . "/"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - } - if ($action == 'update_extras') { // Fill array 'array_options' with data from add form @@ -1924,7 +1887,7 @@ else $head = facturefourn_prepare_head($object); $titre=$langs->trans('SupplierInvoice'); - dol_fiche_head($head, 'card', $titre, 0, 'bill'); + dol_fiche_head($head, 'card', $titre, -1, 'bill'); // Clone confirmation if ($action == 'clone') @@ -2792,8 +2755,8 @@ else * Documents generes */ $ref=dol_sanitizeFileName($object->ref); - $subdir = get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; + $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref; + $filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir; $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed=$user->rights->fournisseur->facture->creer; $delallowed=$user->rights->fournisseur->facture->supprimer; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index cafc6c1a496..0f56c5f7bae 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -138,7 +138,7 @@ if ($id > 0 || ! empty($ref)) $head = facturefourn_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), 0, 'bill'); + dol_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), -1, 'bill'); $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 2563a176346..ab56a66d8a7 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -89,7 +89,7 @@ llxHeader('', $title, $helpurl); if ($object->id > 0) { $head = facturefourn_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), 0, 'bill'); + dol_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), -1, 'bill'); $totalpaye = $object->getSommePaiement(); @@ -230,6 +230,8 @@ if ($object->id > 0) print '
    '; + print '
    '; + print ''; // Nb of files diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index af98c4f9b66..f5ab9164042 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -59,7 +59,7 @@ $alreadypaid=$object->getSommePaiement(); $head = facturefourn_prepare_head($object); $titre=$langs->trans('SupplierInvoice'); -dol_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), 0, 'bill'); +dol_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'bill'); $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index cd009e394f6..9df425040e1 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -79,11 +79,9 @@ if ($object->id > 0) $head = facturefourn_prepare_head($object); $titre=$langs->trans('SupplierInvoice'); - dol_fiche_head($head, 'note', $titre, 0, 'bill'); + dol_fiche_head($head, 'note', $titre, -1, 'bill'); - print '
    '; - // Supplier invoice card $linkback = ''.$langs->trans("BackToList").''; @@ -135,7 +133,9 @@ if ($object->id > 0) print '
    '; print '
    '; - // Type + print '
    '; + + // Type print ''; } + /* Not for supplier proposals if ($soc->outstanding_limit) { // Outstanding Bill @@ -1540,7 +1537,7 @@ if ($action == 'create') print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print ''; print ''; - } + }*/ if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 65efb97f824..58ff9dd3ded 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2855,7 +2855,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ", ".$this->multicurrency_total_ht; $sql.= ", ".$this->multicurrency_total_tva; $sql.= ", ".$this->multicurrency_total_ttc; - $sql.= ", ".$this->fk_unit; + $sql.= ", fk_unit=".($this->fk_unit?$this->fk_unit:'null'); $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); @@ -3025,13 +3025,13 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); - + $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); + // Multicurrency $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " , fk_unit=".$this->fk_unit; $sql.= " WHERE rowid = ".$this->rowid; From de356a318586d8927caabd9d28b336d4a7967536 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 12:41:31 +0200 Subject: [PATCH 148/172] =?UTF-8?q?Revert=20"FIX=20:=20close=20supplier=20?= =?UTF-8?q?makes=20no=20sense.=20we=20just=20need=20to=20know=20if=20it=20?= =?UTF-8?q?is=20ac=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/supplier_proposal/card.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 86813222b6d..7e63dad93e9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -441,6 +441,14 @@ if (empty($reshook)) } } + // Close proposal + else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == 2) { + $object->setStatut(4); + } + } + // Set accepted/refused else if ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) { if (! GETPOST('statut')) { @@ -1768,6 +1776,12 @@ if ($action == 'create') print '>' . $langs->trans('SetAcceptedRefused') . ''; } + // Close + if ($object->statut == 2 && $user->rights->supplier_proposal->cloturer) { + print ''; + } + // Clone if ($user->rights->supplier_proposal->creer) { print ''; From 884b261df518c622470d0ec19ebfe2f40d7652a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 12:51:47 +0200 Subject: [PATCH 149/172] Code comment --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 58ff9dd3ded..7d5997c849e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -154,7 +154,7 @@ class SupplierProposal extends CommonObject */ const STATUS_SIGNED = 2; /** - * Not signed quote + * Not signed quote, canceled */ const STATUS_NOTSIGNED = 3; /** From 90542d119a17ab92048f0e9da7acb03e9e9f04c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 13:25:30 +0200 Subject: [PATCH 150/172] FIX trigger name and status set of setStatus for commercial proposal --- htdocs/core/class/commonobject.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16bff11b5fd..d732e8b9b69 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2790,6 +2790,8 @@ abstract class CommonObject { global $user,$langs,$conf; + $savElementId=$elementId; // To be used later to know if we were using the method using the id of this or not. + $elementId = (!empty($elementId)?$elementId:$this->id); $elementTable = (!empty($elementType)?$elementType:$this->table_element); @@ -2813,11 +2815,13 @@ abstract class CommonObject $error = 0; $trigkey=''; - if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; + if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class + if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class + if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; - + if ($trigkey) { // Appel des triggers @@ -2833,12 +2837,14 @@ abstract class CommonObject if (! $error) { $this->db->commit(); - if (empty($elementId)) // If the element we update was $this (so $elementId is null) + + if (empty($savElementId)) // If the element we update was $this (so $elementId is null) { $this->statut = $status; $this->status = $status; } - return 1; + + return 1; } else { From 0bffac6dc4c4891f033b3a759ddd82ca5e0244b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 13:43:43 +0200 Subject: [PATCH 151/172] Use constant vor status. --- htdocs/comm/propal/class/propal.class.php | 4 +- .../mysql/tables/llx_supplier_proposal.sql | 12 +++--- htdocs/supplier_proposal/card.php | 40 +++++++++---------- .../class/supplier_proposal.class.php | 7 ++-- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 348ca1938b0..8b594d57631 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -187,7 +187,7 @@ class Propal extends CommonObject /** * Billed or processed quote */ - const STATUS_BILLED = 4; + const STATUS_BILLED = 4; // Todo rename into STATUS_CLOSE ? /** * Constructor @@ -1301,7 +1301,7 @@ class Propal extends CommonObject $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->statut = $obj->fk_statut; + $this->statut = (int) $obj->fk_statut; $this->statut_libelle = $obj->statut_label; $this->datec = $this->db->jdate($obj->datec); // TODO deprecated diff --git a/htdocs/install/mysql/tables/llx_supplier_proposal.sql b/htdocs/install/mysql/tables/llx_supplier_proposal.sql index 43f26ee0459..13d9ba3a59a 100644 --- a/htdocs/install/mysql/tables/llx_supplier_proposal.sql +++ b/htdocs/install/mysql/tables/llx_supplier_proposal.sql @@ -18,7 +18,7 @@ CREATE TABLE llx_supplier_proposal ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, ref varchar(30) NOT NULL, - entity integer NOT NULL DEFAULT '1', + entity integer NOT NULL DEFAULT 1, ref_ext varchar(255) DEFAULT NULL, ref_int varchar(255) DEFAULT NULL, fk_soc integer DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE llx_supplier_proposal ( fk_user_modif integer DEFAULT NULL, fk_user_valid integer DEFAULT NULL, fk_user_cloture integer DEFAULT NULL, - fk_statut smallint NOT NULL DEFAULT '0', -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=closed - price double DEFAULT '0', - remise_percent double DEFAULT '0', - remise_absolue double DEFAULT '0', - remise double DEFAULT '0', + fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed + price double DEFAULT 0, + remise_percent double DEFAULT 0, + remise_absolue double DEFAULT 0, + remise double DEFAULT 0, total_ht double(24,8) DEFAULT 0, tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 7e63dad93e9..b230133d7b8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -261,7 +261,7 @@ if (empty($reshook)) $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note'); - $object->statut = 0; + $object->statut = SupplierProposal::STATUS_DRAFT; $id = $object->create_from($user); } else { @@ -436,16 +436,16 @@ if (empty($reshook)) // Reopen proposal else if ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) { // prevent browser refresh from reopening proposal several times - if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) { - $object->reopen($user, 1); + if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) { + $object->reopen($user, SupplierProposal::STATUS_VALIDATED); } } // Close proposal else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) { - // prevent browser refresh from reopening proposal several times - if ($object->statut == 2) { - $object->setStatut(4); + // prevent browser refresh from reopening proposal several times + if ($object->statut == SupplierProposal::STATUS_SIGNED) { + $object->setStatut(SupplierProposal::STATUS_CLOSE); } } @@ -456,7 +456,7 @@ if (empty($reshook)) $action = 'statut'; } else { // prevent browser refresh from closing proposal several times - if ($object->statut == 1) { + if ($object->statut == SupplierProposal::STATUS_VALIDATED) { $object->cloture($user, GETPOST('statut'), GETPOST('note')); } } @@ -1239,7 +1239,7 @@ if ($action == 'create') $sql .= ", " . MAIN_DB_PREFIX . "societe s"; $sql .= " WHERE s.rowid = p.fk_soc"; $sql .= " AND p.entity = " . $conf->entity; - $sql .= " AND p.fk_statut <> 0"; + $sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT; $sql .= " ORDER BY Id"; $resql = $db->query($sql); @@ -1658,7 +1658,7 @@ if ($action == 'create') '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + if (! empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } @@ -1673,12 +1673,10 @@ if ($action == 'create') $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $user->rights->supplier_proposal->creer) + if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) { if ($action != 'editline') { - $var = true; - // Add products/services form $object->formAddObjectLine(1, $soc, $mysoc); @@ -1735,7 +1733,7 @@ if ($action == 'create') if ($action != 'statut' && $action != 'editline') { // Validate - if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && + if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) ) { @@ -1745,18 +1743,18 @@ if ($action == 'create') } // Edit - if ($object->statut == 1 && $user->rights->supplier_proposal->creer) { + if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->creer) { print ''; } // ReOpen - if (($object->statut == 2 || $object->statut == 3 || $object->statut == 4) && $user->rights->supplier_proposal->cloturer) { + if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $user->rights->supplier_proposal->cloturer) { print ''; } // Send - if ($object->statut == 1 || $object->statut == 2) { + if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { print ''; } else @@ -1764,20 +1762,20 @@ if ($action == 'create') } // Create an order - if (! empty($conf->commande->enabled) && $object->statut == 2) { + if (! empty($conf->commande->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($user->rights->fournisseur->commande->creer) { print ''; } } // Set accepted/refused - if ($object->statut == 1 && $user->rights->supplier_proposal->cloturer) { + if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->cloturer) { print ''; } // Close - if ($object->statut == 2 && $user->rights->supplier_proposal->cloturer) { + if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) { print ''; } @@ -1788,7 +1786,7 @@ if ($action == 'create') } // Delete - if (($object->statut == 0 && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) { + if (($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) { print ''; } @@ -1811,8 +1809,6 @@ if ($action == 'create') $genallowed = $user->rights->supplier_proposal->creer; $delallowed = $user->rights->supplier_proposal->supprimer; - $var = true; - print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 7d5997c849e..b140daa280c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -158,9 +158,9 @@ class SupplierProposal extends CommonObject */ const STATUS_NOTSIGNED = 3; /** - * Billed or processed quote + * Billed or closed/processed quote */ - const STATUS_BILLED = 4; + const STATUS_CLOSE = 4; @@ -1143,9 +1143,8 @@ class SupplierProposal extends CommonObject $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->statut = $obj->fk_statut; + $this->statut = (int) $obj->fk_statut; $this->statut_libelle = $obj->statut_label; - $this->datec = $this->db->jdate($obj->datec); // TODO deprecated $this->datev = $this->db->jdate($obj->datev); // TODO deprecated $this->date_creation = $this->db->jdate($obj->datec); //Creation date From d60e98a7976ff87f4b1984850c33c83aae2c6f66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 13:48:40 +0200 Subject: [PATCH 152/172] No payment information on a supplier proposal by default. --- .../supplier_proposal/doc/pdf_aurore.modules.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 3b2812c7b90..6efe3ead81c 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -635,16 +635,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('','', $default_font_size - 1); - // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - - $posy=$pdf->GetY()+4; - } - $posxval=52; // Show shipping date @@ -723,7 +713,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy=$pdf->GetY()+3; } - if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND)) + if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMCOND)) { // Show payment mode if ($object->mode_reglement_code @@ -1037,7 +1027,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $resteapayer = $object->total_ttc - $deja_regle; if (! empty($object->paye)) $resteapayer=0; */ - + if ($deja_regle > 0) { $index++; From a1ac3b470bb8a3a93f95c987672a1fa6a13e3b2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 14:01:20 +0200 Subject: [PATCH 153/172] Change menu for setup of predefined emails --- htdocs/core/class/html.formmail.class.php | 4 ++-- htdocs/langs/en_US/main.lang | 3 ++- htdocs/langs/en_US/other.lang | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index ab58854f2c4..1d5e8714aad 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -327,7 +327,7 @@ class FormMail extends Form { $out.= '
    '."\n"; $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; $out.= '   '; @@ -341,7 +341,7 @@ class FormMail extends Form { $out.= '
    '."\n"; $out.= $langs->trans('SelectMailModel').': '; // Do not put disabled on option, it is already on select and it makes chrome crazy. - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; $out.= '   '; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index bc7c864b279..9453c1522e9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -611,7 +611,8 @@ PartialWoman=Partial TotalWoman=Total NeverReceived=Never received Canceled=Canceled -YouCanChangeValuesForThisListFromDictionarySetup=You can change values for this list from menu setup - dictionary +YouCanChangeValuesForThisListFromDictionarySetup=You can change values for this list from menu Setup - Dictionaries +YouCanChangeValuesForThisListFrom=You can change values for this list from menu %s YouCanSetDefaultValueInModuleSetup=You can set the default value used when creating a new record into module setup Color=Color Documents=Linked files diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index ab937ff3bab..a37927566e3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -61,7 +61,7 @@ PredefinedMailTestHtml=This is a test mail (the word test must be in bold PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__\n\nWe would like to warn you that the invoice __REF__ seems to not being payed. So this is the invoice in attachment again, as a reminder.\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendProposal=__CONTACTCIVNAME__\n\nYou will find here the commercial proposal __PROPREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendSupplierProposal=__CONTACTCIVNAME__\n\nYou will find here the price request __ASKREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ +PredefinedMailContentSendSupplierProposal=__CONTACTCIVNAME__\n\nYou will find here the price request __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendOrder=__CONTACTCIVNAME__\n\nYou will find here the order __ORDERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here our order __ORDERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ From 919d5b2ef3b16e59d48c00fbc6f9a5461e4b0a95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 14:01:32 +0200 Subject: [PATCH 154/172] Fix missing translation --- htdocs/supplier_proposal/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b230133d7b8..d36b471a721 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1855,6 +1855,7 @@ if ($action == 'create') $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('commercial'); + $outputlangs->load('supplier_proposal'); } // Build document if it not exists From 91c505c9c970f09029f75b40f4715b2f362c60af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 14:20:59 +0200 Subject: [PATCH 155/172] Update llx_accounting.sql --- htdocs/install/mysql/data/llx_accounting.sql | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index c468e4c3968..e81d13dd2b8 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -27,15 +27,11 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -delete from llx_accounting_account; -delete from llx_accounting_system; -delete from llx_accounting_journal; - -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 2, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 3, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 4, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 1, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('VT', 'Journal des ventes', 2, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('AC', 'Journal des achats', 3, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('BQ', 'Journal de banque', 4, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('OD', 'Journal des opérations diverses', 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('AN', 'Journal des à-nouveaux', 9, 1); -- -- Descriptif des plans comptables FR PCG99-ABREGE -- From 885a63635181150ae3b5bc3c880b1f83cda4bc11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 16:35:05 +0200 Subject: [PATCH 156/172] Debug new journal list page --- htdocs/accountancy/admin/journals_list.php | 41 ++++++++----------- htdocs/accountancy/index.php | 16 +++++--- htdocs/core/class/translate.class.php | 1 + .../install/mysql/migration/5.0.0-6.0.0.sql | 7 ++++ htdocs/langs/en_US/accountancy.lang | 28 +++++++------ 5 files changed, 50 insertions(+), 43 deletions(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index be532c7c25f..065d750ca82 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -126,10 +126,10 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort, // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); $sourceList = array( - '1' => $langs->trans('AccountingJournalType0'), - '2' => $langs->trans('AccountingJournalType1'), - '3' => $langs->trans('AccountingJournalType2'), - '4' => $langs->trans('AccountingJournalType3'), + '1' => $langs->trans('AccountingJournalType1'), + '2' => $langs->trans('AccountingJournalType2'), + '3' => $langs->trans('AccountingJournalType3'), + '4' => $langs->trans('AccountingJournalType4'), '9' => $langs->trans('AccountingJournalType9') ); @@ -212,10 +212,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i=0; foreach ($listfieldinsert as $f => $value) { - if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') { - $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); - } - else if ($value == 'entity') { + if ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql.=","; @@ -465,7 +462,6 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - if ($id == 4) print '
    '; print ''; @@ -475,7 +471,7 @@ if ($id) print ''; // Line to enter new values - print ""; + print ''; $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. @@ -503,13 +499,7 @@ if ($id) print ''; print ""; - $colspan=count($fieldlist)+3; - - if (! empty($alabelisused)) // If there is one label among fields, we show legend of * - { - print ''; - } - print ''; // Keep   to have a line with enough height + print ''; // Keep   to have a line with enough height } @@ -578,6 +568,9 @@ if ($id) print ''; print ''; print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; } else @@ -655,10 +646,7 @@ if ($id) else if ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } } - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } $canbemodified=$iserasable; - if ($obj->code == 'RECEP') $canbemodified=1; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); if ($param) $url .= '&'.$param; @@ -690,9 +678,12 @@ if ($id) } else print ''; + print ''; + print ''; - print "\n"; } + + print "\n"; $i++; } } diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index ff9ca6fa1a3..c7caa5daac3 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -71,6 +71,10 @@ print "
    \n"; // STEPS $step++; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").''); +print "
    \n"; +print "
    \n"; +$step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").''); print "
    \n"; print "
    \n"; @@ -148,24 +152,26 @@ print '
    '; print "
    \n"; $step = 0; +$langs->loadLangs(array('bills', 'trips')); + $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescCustomer", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'')."
    \n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'')."
    \n"; print "
    \n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSupplier", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'')."
    \n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'')."
    \n"; print "
    \n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."
    \n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."
    \n"; print "
    \n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", $step)."
    \n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."
    \n"; print "
    \n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", $step)."
    \n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."
    \n"; print "
    \n"; llxFooter(); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 30cedf57d51..0f2e6a837ef 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -170,6 +170,7 @@ class Translate * @param int $forcelangdir To force a different lang directory * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf. * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK + * @see loadLangs */ function load($domain,$alt=0,$stopafterdirection=0,$forcelangdir='',$loadfromfileonly=0) { diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index a6666d37ee0..f88ffd05687 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -251,3 +251,10 @@ insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); +UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0; +UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1; +UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; +UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; + + + diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a5788736fbd..9eb4135397f 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -32,23 +32,25 @@ ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: AccountancyAreaDescActionOnce=The following actions are usually executed one time only, or once per year... -AccountancyAreaDescActionOnceBis=Next steps should be done to save you time in future by suggesting you the correct default accounting account when making thee journalization (writing record in Journals and General ledger) +AccountancyAreaDescActionOnceBis=Next steps should be done to save you time in future by suggesting you the correct default accounting account when making the journalization (writing record in Journals and General ledger) AccountancyAreaDescActionFreq=The following actions are usually executed every month, week or day for very large companies... + +AccountancyAreaDescJournalSetup=STEP %s: Create or check content of your journal list from menu %s AccountancyAreaDescChartModel=STEP %s: Create a model of chart of account from menu %s AccountancyAreaDescChart=STEP %s: Create or check content of your chart of account from menu %s -AccountancyAreaDescVat=STEP %s: Define accounting accounts for each VAT Rates. For this you can use the menu entry %s. -AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for type of expense report. For this you can use the menu entry %s. -AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this you can use the menu entry %s. -AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this you can use the menu entry %s. -AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this you can use the menu entry %s. -AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this you can use the menu entry %s. -AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this you can use the menu entry %s. -AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. -AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products. For this you can use the menu entry %s. -AccountancyAreaDescCustomer=STEP %s: Check the binding between existing customer invoice lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescSupplier=STEP %s: Check the binding between existing supplier invoice lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into each Journal, and click into button "Journalize transactions in General Ledger". +AccountancyAreaDescVat=STEP %s: Define accounting accounts for each VAT Rates. For this, use the menu entry %s. +AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for each type of expense report. For this, use the menu entry %s. +AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s. +AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s. +AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s. +AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. +AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s. +AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. +AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. + +AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this, use the menu entry %s. +AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into menu %s, and click into button %s. AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and generate reports and exports. AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. From fc5f4007a12e3e1cffb93f928d9d2bc02dbd9aef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 16:54:05 +0200 Subject: [PATCH 157/172] Debug accountancy module. Page for bank journalization is still KO. --- htdocs/accountancy/admin/journals_list.php | 5 +++- htdocs/core/menus/standard/eldy.lib.php | 29 +++++++++++++------ .../install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ .../mysql/tables/llx_accounting_journal.sql | 1 + 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 065d750ca82..0b13bfc7d4d 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -61,6 +61,8 @@ if ($page == -1) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +if (empty($sortfield)) $sortfield='code'; +if (empty($sortorder)) $sortorder='ASC'; $error = 0; @@ -125,7 +127,8 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort, // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); - $sourceList = array( + // Must match ids defined into eldy.lib.php + $sourceList = array( '1' => $langs->trans('AccountingJournalType1'), '2' => $langs->trans('AccountingJournalType2'), '3' => $langs->trans('AccountingJournalType3'), diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index aa905b4ef93..4c873830948 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1007,8 +1007,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Multi journal $sql = "SELECT rowid, code, label, nature"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; - // $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY code"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " ORDER BY nature"; $resql = $db->query($sql); if ($resql) @@ -1021,14 +1021,25 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu while ($i < $numr) { $objp = $db->fetch_object($resql); - - if ($objp->nature == 1) $nature="sells"; - if ($objp->nature == 2) $nature="purchases"; - if ($objp->nature == 3) $nature="bank"; - if ($objp->nature == 4) $nature="various"; + + $nature=''; + // Must match array $sourceList defined into journals_list.php + if ($objp->nature == 2) $nature="sells"; + if ($objp->nature == 3) $nature="purchases"; + if ($objp->nature == 4) $nature="bank"; + if ($objp->nature == 1) $nature="various"; if ($objp->nature == 9) $nature="hasnew"; - - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&code_journal='.$objp->code,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); + + // To enable when page exists + if (empty($conf->global->MAIN_FEATURES_LEVEL)) + { + if ($nature == 'various' || $nature == 'hasnew') $nature=''; + } + + if ($nature) + { + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&code_journal='.$objp->code,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); + } $i++; } } diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index f88ffd05687..d96210dcbfe 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -120,6 +120,8 @@ INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES ( INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 0, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1); +ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1; + ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql index bccfb234c3e..a435de3cd80 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql @@ -20,6 +20,7 @@ create table llx_accounting_journal ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1, code varchar(32) NOT NULL, label varchar(128) NOT NULL, nature smallint DEFAULT 0 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) From dc9cbed8664f66d028f68a90c6fb3d46a66bcf95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 17:04:35 +0200 Subject: [PATCH 158/172] Look and feel v6 --- htdocs/margin/productMargins.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index efcb35b802f..f5e84dd5c04 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -204,6 +204,7 @@ if ($result) print '
    '; print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,$num,''); + //var_dump($conf->global->MARGIN_TYPE); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' @@ -285,7 +286,7 @@ if ($result) } else { - print $langs->trans("NotPredefinedProducts"); + print img_object('', 'product').' '.$langs->trans("NotPredefinedProducts"); } print "\n"; //print "
    \n"; From a8292ce990f53be1fd6a298d324d2187dfa03c0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 17:27:16 +0200 Subject: [PATCH 159/172] Code comment --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index a8b248dd38e..2e2a26dd9ae 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -91,8 +91,8 @@ abstract class CommonInvoice extends CommonObject /** - * Return remain amount to pay. - * Property ->id and ->total_ttc must be set. + * Return remain amount to pay. Property ->id and ->total_ttc must be set. + * This does not include open direct debit requests. * * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Remain of amount to pay From 15d20497c878b29ab5c1be27d6f8a230dcb26cad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 17:28:33 +0200 Subject: [PATCH 160/172] FIX #6795 #6796 --- htdocs/compta/facture/class/facture.class.php | 7 +++--- .../core/class/commondocgenerator.class.php | 23 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index bc4cf3626a4..912a18979bc 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3560,10 +3560,11 @@ class Facture extends CommonInvoice /** - * Create a withdrawal request for a standing order + * Create a withdrawal request for a standing order. + * Use the remain to pay excluding all existing open direct debit requests. * - * @param User $fuser User asking standing order - * @param float $amount Amount we request withdraw for + * @param User $fuser User asking the direct debit transfer + * @param float $amount Amount we request direct debit for * @return int <0 if KO, >0 if OK */ function demande_prelevement($fuser, $amount=0) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f338aca7be8..bb806257d01 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -333,7 +333,7 @@ abstract class CommonDocGenerator { global $conf; - $sumpayed=''; $alreadypayed=''; + $sumpayed=$sumdeposit=$sumcreditnote=''; if ($object->element == 'facture') { $invoice_source=new Facture($this->db); @@ -342,7 +342,8 @@ abstract class CommonDocGenerator $invoice_source->fetch($object->fk_facture_source); } $sumpayed = $object->getSommePaiement(); - $alreadypayed=price($sumpayed,0,$outputlangs); + $sumdeposit = $object->getSumDepositsUsed(); + $sumcreditnote = $object->getSumCreditNotesUsed(); } $resarray=array( @@ -385,11 +386,21 @@ abstract class CommonDocGenerator $array_key.'_note_private'=>$object->note, $array_key.'_note_public'=>$object->note_public, $array_key.'_note'=>$object->note_public, // For backward compatibility + // Payments - $array_key.'_already_payed_locale'=>price($alreadypayed, 0, $outputlangs), - $array_key.'_remain_to_pay_locale'=>price($object->total_ttc - $sumpayed, 0, $outputlangs), - $array_key.'_already_payed'=>$alreadypayed, - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed) + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), + $array_key.'_already_payed'=>price2num($sumpayed), + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), + $array_key.'_already_deposit'=>price2num($sumdeposit), + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), + $array_key.'_already_creditnote'=>price2num($sumcreditnote), + + $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), + $array_key.'already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), + + // Remain to pay with all know infrmation (except open direct debit requests) + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') ); // Add vat by rates From 57e540af5374ce5a719ccdabdc0532da7af06ae1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 17:46:40 +0200 Subject: [PATCH 161/172] For better compatibility with module for 6.0 --- htdocs/core/lib/functions.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c05d9268b74..8d14a377c75 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -802,6 +802,8 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { global $conf, $langs, $hookmanager; + if ($notab == -1) $notab = 0; // For better compatiblity with modules for 6.0 + $out="\n".'
    '."\n"; // Show title From d7e10085b8782f3261b3c717e8e5b0dd36f84021 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 18:42:11 +0200 Subject: [PATCH 162/172] Clean code. Using 2 different key for a param is not more allowed. --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/index.php | 19 +-- htdocs/comm/action/listactions.php | 4 +- htdocs/comm/action/pertype.php | 8 +- htdocs/comm/action/peruser.php | 9 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 120 +++++++++--------- .../demo_wsclient_actioncomm.php-NORUN | 3 +- htdocs/webservices/server_actioncomm.php | 12 +- 9 files changed, 80 insertions(+), 99 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fc4fc218971..73d015d7db9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -337,7 +337,7 @@ if ($action == 'add') unset($_SESSION['assignedtouser']); $moreparam=''; - if ($user->id != $object->userownerid) $moreparam="usertodo=-1"; // We force to remove filter so created record is visible when going back to per user view. + if ($user->id != $object->userownerid) $moreparam="filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. $db->commit(); if (! empty($backtopage)) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d365acef38b..47ef8093c1a 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -43,8 +43,8 @@ if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MA if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -$filter=GETPOST("filter",'',3); -$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); +$filter = GETPOST("filter",'',3); +$filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -1155,21 +1155,6 @@ else // View by day echo '
    '.$langs->trans('Type').''; print $object->getLibType(); if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) @@ -203,6 +203,7 @@ if ($object->id > 0) print '
    '; + print '
    '; $cssclass="titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1356a980164..7f0596d33cd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1154,6 +1154,7 @@ WebCalUrlForVCalExport=An export link to %s format is available at follow BillsSetup=Invoices module setup BillsNumberingModule=Invoices and credit notes numbering model BillsPDFModules=Invoice documents models +PaymentsPDFModules=Payment documents models CreditNote=Credit note CreditNotes=Credit notes ForceInvoiceDate=Force invoice date to validation date diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 0bac6dab14f..7e63dad93e9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin @@ -462,13 +462,9 @@ if (empty($reshook)) } } + // Action for direct print include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - /* - * Send mail - */ - // Actions to send emails $actiontypecode='AC_ASKPRICE'; $trigger_name='SUPPLIER_PROPOSAL_SENTBYMAIL'; @@ -1530,6 +1526,7 @@ if ($action == 'create') print '
    '; print ''; print '
    * '.$langs->trans("LabelUsedByDefault").'.
     
     
    '; if ($filterfound) { @@ -605,14 +598,12 @@ if ($id) // Show fields if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); - print ''; + print ''; print ''; print ''; print ''; - print '
    '; print ''; + print '
    '; print '
     
    ".$product_static->getNomUrl(1)."
    '; } - -/* TODO Export - print ' - - - - - -'; -*/ - llxFooter(); $db->close(); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 8b1dc424239..3e6224e0c41 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -64,8 +64,8 @@ $dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth'), GETPOST('dateendday'), GET if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -$filter=GETPOST("filter",'',3); -$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); +$filter = GETPOST("filter",'',3); +$filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 4f4ef6a580c..544da904cdc 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -38,8 +38,8 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; -$filter=GETPOST("filter",'',3); -$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); +$filter = GETPOST("filter",'',3); +$filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -250,7 +250,7 @@ $picto='calendarweek'; $nav.='  
    '; $nav.=''; $nav.=''; -$nav.=''; +$nav.=''; $nav.=''; $nav.=''; $nav.=''; @@ -714,7 +714,7 @@ jQuery(document).ready(function() { else if (ids.indexOf(",") > -1) /* There is several events */ { /* alert(\'several events\'); */ - url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day; + url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day; window.location.href = url; } else /* One event */ diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 61bf98634c4..2a707cd2d8f 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -38,8 +38,8 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; -$filter=GETPOST("filter",'',3); -$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); +$filter = GETPOST("filter",'',3); +$filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -252,7 +252,7 @@ $picto='calendarweek'; $nav.='   '; $nav.=''; $nav.=''; -$nav.=''; +$nav.=''; $nav.=''; $nav.=''; $nav.=''; @@ -663,7 +663,6 @@ else if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user',1).")"; if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; - //if (GETPOST("usertodo","int",3) > 0) $sql.=" AND u.rowid = ".GETPOST("usertodo","int",3); //print $sql; $resql=$db->query($sql); if ($resql) @@ -816,7 +815,7 @@ jQuery(document).ready(function() { else if (ids.indexOf(",") > -1) /* There is several events */ { /* alert(\'several events\'); */ - url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day; + url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day; window.location.href = url; } else /* One event */ diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 1f83690b096..4e9b458c3d0 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -76,7 +76,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("ActionsToDoBy").'   '; print ''; - print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($filtert, 'filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").'   '; print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 275bbae8c36..31f29ff611c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -248,70 +248,72 @@ function dol_shutdown() */ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) { - if (empty($method)) - { - $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); - - // Management of default values - if (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values - { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - { - $relativepathstring = $_SERVER["PHP_SELF"]; - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - global $user; - if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first - { - //var_dump($user->default_values[$relativepathstring]['createform']); - if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; - } - } - // Management of default search_filters and sort order - elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - { - $relativepathstring = $_SERVER["PHP_SELF"]; - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - global $user; - if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first - { - //var_dump($user->default_values[$relativepathstring]); - if ($paramname == 'sortfield') - { - if (isset($user->default_values[$relativepathstring]['sortorder'])) - { - foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) - { - if ($out) $out.=', '; - $out.=$key; - } - } - } - elseif ($paramname == 'sortorder') - { - if (isset($user->default_values[$relativepathstring]['sortorder'])) - { - foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) - { - if ($out) $out.=', '; - $out.=$val; - } - } - } - elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; - } - } - } - } + if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); elseif ($method==4) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:(isset($_COOKIE[$paramname])?$_COOKIE[$paramname]:'')); else return 'BadThirdParameterForGETPOST'; - + + if (empty($method) || $method == 3 || $method == 4) + { + // Management of default values + if (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values + { + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + } + } + // Management of default search_filters and sort order + //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values + { + //var_dump($user->default_values[$relativepathstring]); + if ($paramname == 'sortfield') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=dol_string_nospecial($key, ''); + } + } + } + elseif ($paramname == 'sortorder') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=dol_string_nospecial($val, ''); + } + } + } + elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname])) + $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], ''); + } + } + } + } + if (! empty($check)) { // Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__ diff --git a/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN b/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN index d3044fc9bd8..d8ad49945bd 100755 --- a/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN +++ b/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN @@ -107,8 +107,7 @@ if ($action=='create') 'projectid'=>'', 'note'=>'This is note', 'contactid'=>'', - 'usertodo'=>'1', - 'userdone'=>'1', + 'userownerod'=>'1', 'label'=>'Ceci est les titre de l\'envenement', 'percentage'=>'100', 'location'=>'Location1' diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 99e8ea59e6f..c7e1f769d9a 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -101,8 +101,7 @@ $actioncomm_fields= array( 'percentage' => array('name'=>'percentage','type'=>'xsd:string'), 'author' => array('name'=>'author','type'=>'xsd:string'), 'usermod' => array('name'=>'usermod','type'=>'xsd:string'), - 'usertodo' => array('name'=>'usertodo','type'=>'xsd:string'), - 'userdone' => array('name'=>'userdone','type'=>'xsd:string'), + 'userownerid' => array('name'=>'userownerid','type'=>'xsd:string'), 'priority' => array('name'=>'priority','type'=>'xsd:string'), 'fulldayevent' => array('name'=>'fulldayevent','type'=>'xsd:string'), 'location' => array('name'=>'location','type'=>'xsd:string'), @@ -291,8 +290,7 @@ function getActionComm($authentication,$id) 'percentage'=> $actioncomm->percentage, 'author'=> $actioncomm->authorid, 'usermod'=> $actioncomm->usermodid, - 'usertodo'=> $actioncomm->userownerid, - 'userdone'=> $actioncomm->userdoneid, + 'userownerid'=> $actioncomm->userownerid, 'priority'=> $actioncomm->priority, 'fulldayevent'=> $actioncomm->fulldayevent, 'location'=> $actioncomm->location, @@ -437,8 +435,7 @@ function createActionComm($authentication,$actioncomm) $newobject->fk_project=$actioncomm['projectid']; $newobject->note=$actioncomm['note']; $newobject->contactid=$actioncomm['contactid']; - $newobject->userownerid=$actioncomm['usertodo']; - $newobject->userdoneid=$actioncomm['userdone']; + $newobject->userownerid=$actioncomm['userownerid']; $newobject->label=$actioncomm['label']; $newobject->percentage=$actioncomm['percentage']; $newobject->priority=$actioncomm['priority']; @@ -532,8 +529,7 @@ function updateActionComm($authentication,$actioncomm) $object->contactid=$actioncomm['contactid']; $object->fk_project=$actioncomm['projectid']; $object->note=$actioncomm['note']; - $object->userownerid=$actioncomm['usertodo']; - $object->userdoneid=$actioncomm['userdone']; + $object->userownerid=$actioncomm['userownerid']; $object->label=$actioncomm['label']; $object->percentage=$actioncomm['percentage']; $object->priority=$actioncomm['priority']; From d53654e64f46ff71aa5f4b87f62557371471b614 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 20:41:44 +0200 Subject: [PATCH 163/172] Look and feel v6 --- htdocs/admin/ihm.php | 44 ------------------- htdocs/admin/pdf.php | 9 ++-- htdocs/comm/action/card.php | 8 ++-- htdocs/core/class/html.formactions.class.php | 5 ++- htdocs/core/lib/functions.lib.php | 4 +- htdocs/core/lib/security2.lib.php | 6 --- htdocs/core/lib/usergroups.lib.php | 13 ++++-- htdocs/holiday/list.php | 1 + htdocs/projet/activity/perday.php | 38 ++++++++-------- htdocs/projet/activity/perweek.php | 40 ++++++++--------- htdocs/theme/doliforge_logo.png | Bin 16587 -> 0 bytes htdocs/theme/eldy/style.css.php | 22 +++++----- htdocs/theme/md/style.css.php | 7 ++- htdocs/user/note.php | 1 + htdocs/user/passwordforgotten.php | 9 ---- 15 files changed, 80 insertions(+), 127 deletions(-) delete mode 100644 htdocs/theme/doliforge_logo.png diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 193ee35a80f..739a6fa4c88 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -50,18 +50,6 @@ $action = GETPOST('action'); if (! defined("MAIN_MOTD")) define("MAIN_MOTD",""); -// List of supported permanent search area -$searchform=array(); -/* deprecated -if (empty($conf->use_javascript_ajax)) -{ - $searchform=array("MAIN_SEARCHFORM_SOCIETE", "MAIN_SEARCHFORM_CONTACT", "MAIN_SEARCHFORM_PRODUITSERVICE", "MAIN_SEARCHFORM_ADHERENT", "MAIN_SEARCHFORM_PROJECT", "MAIN_SEARCHFORM_EMPLOYEE"); - $searchformconst=array($conf->global->MAIN_SEARCHFORM_SOCIETE,$conf->global->MAIN_SEARCHFORM_CONTACT,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE,$conf->global->MAIN_SEARCHFORM_ADHERENT,$conf->global->MAIN_SEARCHFORM_PROJECT,$conf->global->MAIN_SEARCHFORM_EMPLOYEE); - $searchformtitle=array($langs->trans("Companies"), $langs->trans("Contacts"), $langs->trans("ProductsAndServices"), $langs->trans("Members"), $langs->trans("Projects"), $langs->trans("Users")); - $searchformmodule=array('Module1Name','Module1Name','Module50Name','Module310Name','Module400Name'); -} -*/ - /* * Action @@ -275,21 +263,6 @@ if ($action == 'edit') // Edit show_theme(null,1); print '
    '; - // List of permanent supported search box - if (! empty($searchform)) - { - print ''; - print ''; - foreach ($searchform as $key => $value) - { - print ''; - } - print '
    '.$langs->trans("PermanentLeftSearchForm").''.$langs->trans("Activated").'
    '.$searchformtitle[$key].''; - print $form->selectyesno($searchform[$key],$searchformconst[$key],1); - print '
    '; - print '
    '; - } - // Other print ''; print ''; @@ -476,23 +449,6 @@ else // Show print '
    '; - // List of search forms to show - if (! empty($searchform)) - { - print '
    '.$langs->trans("Parameters").''.$langs->trans("Value").'
    '; - print ''; - foreach ($searchform as $key => $value) - { - - print ''; - print ''; - } - print '
    '.$langs->trans("PermanentLeftSearchForm").''.$langs->trans("Activated").' 
    '.$searchformtitle[$key].''.yn($searchformconst[$key]).''; - if (! empty($searchformmodule[$key])) print $langs->trans("IfModuleEnabled",$langs->transnoentitiesnoconv($searchformmodule[$key])); - print '
    '; - print '
    '; - } - // Other print ''; print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 2e650c75696..6698be8b01f 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -306,8 +306,9 @@ else // Show $var=true; // Misc options - print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'','').'
    '; - $var=true; + print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'',''); + + print '
    '.$langs->trans("Parameters").''.$langs->trans("Value").'
    '; print ''; @@ -357,7 +358,7 @@ else // Show print '
    '; - print load_fiche_titre($langs->trans("PDFAddressForging"),'','').'
    '; + print load_fiche_titre($langs->trans("PDFAddressForging"),'',''); print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print ''; @@ -444,7 +445,7 @@ else // Show print '
    '; // Other - print load_fiche_titre($langs->trans("Other"),'','').'
    '; + print load_fiche_titre($langs->trans("Other"),'',''); $var=true; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 73d015d7db9..30b13bc3007 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -706,7 +706,7 @@ if ($action == 'create') if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent='0'; else if (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent=100; } - $formactions->form_select_status_action('formaction',$percent,1,'complete'); + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; // Location @@ -1428,7 +1428,7 @@ if ($id > 0) } else { $value = $object->array_options["options_" . $key]; } - print '\n"; } @@ -1491,7 +1491,7 @@ if ($id > 0) { if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) { - print '
     

    '; + print '
    '; print ''; // ancre /* @@ -1512,8 +1512,6 @@ if ($id > 0) print '
    '; - - print '
     
    '; } } } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index b799e0e2359..452ff89d914 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -54,9 +54,10 @@ class FormActions * @param string $htmlname Name of html prefix for html fields (selectX and valX) * @param integer $showempty Show an empty line if select is used * @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running) + * @param string $morecss More css on select field * @return void */ - function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete',$showempty=0,$onlyselect=0) + function form_select_status_action($formname, $selected, $canedit=1, $htmlname='complete', $showempty=0, $onlyselect=0, $morecss='maxwidth100') { global $langs,$conf; @@ -120,7 +121,7 @@ class FormActions { //var_dump($selected); if ($selected == 'done') $selected='100'; - print ''; if ($showempty) print ''; foreach($listofstatus as $key => $val) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 31f29ff611c..262204b9f72 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -257,8 +257,10 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) if (empty($method) || $method == 3 || $method == 4) { + global $conf; + // Management of default values - if (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values + if (! isset($_GET['sortfield']) && empty($conf->global->MAIN_DISABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on { if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 5139128a5d8..a14645a3152 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -197,12 +197,6 @@ function dol_loginfunction($langs,$conf,$mysoc) if (! GETPOST("username")) $focus_element='username'; else $focus_element='password'; - $login_background=DOL_URL_ROOT.'/theme/login_background.png'; - if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png')) - { - $login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'; - } - $demologin=''; $demopassword=''; if (! empty($dolibarr_main_demo)) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 4350edc3797..8936cf98623 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -426,7 +426,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print ''; - // BackgroundColor + // Background color THEME_ELDY_BACKBODY if ($foruserprofile) { /* @@ -609,7 +609,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default")); } - print '   ('.$langs->trans("Default").': 3c3c14) '; + print '   ('.$langs->trans("Default").': 3c3c14) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; @@ -654,9 +654,14 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''); if ($color) print ''; - else print $langs->trans("Default"); + else + { + //print ''; + //print ''.$langs->trans("Default").''; + print $langs->trans("Default"); + } } - print '   ('.$langs->trans("Default").': 000078) '; + print '   ('.$langs->trans("Default").': 000078) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index d9c5fdf43c0..f91616d0b9a 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -282,6 +282,7 @@ print ''; print ''; print ''; print ''; +if ($id > 0) print ''; if ($sall) { diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c50cbd014f7..c1aa8aaa469 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -407,25 +407,7 @@ print '
    '; print '
    '; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$label.''; + print '
    '.$label.''; print $extrafields->showOutputField($key,$value); print "
    '."\n"; -print ''; -print ''; -print ''; -print ''; -if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) -{ - print ''; -} -print ''; -print ''; -print ''; -if ($usertoprocess->id == $user->id) print ''; -else print ''; -print ''; -print ''; -print ''; -print "\n"; - -print ''; +print ''; print ''; print ''; print ''; @@ -444,6 +426,24 @@ print $searchpitco; print ''; print "\n"; +print ''; +print ''; +print ''; +print ''; +if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) +{ + print ''; +} +print ''; +print ''; +print ''; +if ($usertoprocess->id == $user->id) print ''; +else print ''; +print ''; +print ''; +print ''; +print "\n"; + // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 989424afd67..905b93393dd 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -402,6 +402,26 @@ print '
    '; print '
    '; print '
    '.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Note").'
    '.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Note").'
    '."\n"; +print ''; +print ''; +print ''; +print ''; +if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; +print ''; +print ''; +print ''; +print ''; +for($i=0;$i<7;$i++) +{ + print ''; +} +// Action column +print ''; +print "\n"; + print ''; print ''; print ''; @@ -425,26 +445,6 @@ for($i=0;$i<7;$i++) print ''; print "\n"; -print ''; -print ''; -print ''; -print ''; -if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; -print ''; -print ''; -print ''; -print ''; -for($i=0;$i<7;$i++) -{ - print ''; -} -// Action column -print ''; -print "\n"; - // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); diff --git a/htdocs/theme/doliforge_logo.png b/htdocs/theme/doliforge_logo.png deleted file mode 100644 index c9de1b5012c45670d346b4f699a01ab8d257d415..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16587 zcmV)lK%c*fP)bL6Y5D_aHvCe``*T6diDo$q|-ectzZ$M+q@wrw%9&1^H< z`L!uCLvY@W`#EXKKp-HNE?p{u!Jx>^%@w9;3RP7_B9Rcft_#C3&Uifc9UL4Knx@IN z^7Hcrm31^4mB;eEqA2pkeIk*Fh{a-}r>938J9cc!cJuP`#ATOVCfj$FKacfzJi_ny zi{as6`5pVs&uokB@;uz1{iv<2mHp`M?iPiGg`%LKK%6>tN{o$-iR$WV*|r=o>>rQE z<@?^=Ub&yo=aX%>wY7<%p&>DE-aI)T+&D%@jvSHK$Md=45DtgM$&)ALXYOBCRwl2R z*TT)REaCNf%#$UX5K!pEpUr`#z|m2LpxLfd4+r0N z0mAkCtp zB3cCk(qN>?DXe7HVfEN%e67OqWx z2kT0pc`#;P4ZyTDuN_d$f`UZfe6N)#j9P)NAz#5^T=|%4By@~ZjA8f6%1XPlvs2RC zDaJ&m5oWgkI~G%gl~YSgOFcT|$x?L_+8xwQ)d)_Ahe~cLw=?2JAuI*=(RCXRl_i}0 zO~@&*Y8n8&34u2VQuiE&V2_2gIx-HWk+!BaJzsVx5Put{4L zwkfT?$0sZ!$=yMH6$_(8Fne)`uIZX*PWaf{D~H-{4kSgR?hzuH6h_3a?>|;J?`tPK z&v7m{e@)!O~*^n{%U zY4kvwYuJmv7U(RbN1V}O+7_&&p?D$*&EGes1qKY&8wNbb0I|5&Yx@XR6D9%sCLm}A zEE1`l^s#73A#_%nANopJ&hfDzeV1e5@p^okT~KTHU92YTAg-Nbr@=c^-D_2Z0$N}t zRs8K!g8PR&xvhYvBHc__OT6(d8G8Ox<%4~1nz!Ln(X`%rvd6S4)L`V>5xHKLLwL z8^|C9q(W14uT^Oeu3A0P^8Ix4HEq*{oh*};7D5;%+$BYfCNwda^yYMpdBoQmcv zZV(TD_5(tB^pW=udJFb+d5Sg(SY4dkz<4NbWlQ=71ty#Tnn)%R4OSrVX571tP;M2V z&v^p_0}=T2m*YBm&UB440i@ReFzFA$ztQklx5?HFkxQ@d>JNWZR5mpWBaz4o!0f>v zXl@8pVk|6%yE?r?ohOP%dwPn8Pjxi(9%;Ea(tZ4ns9!zUm0$PEu3+Wni0bdqL_8OA z9EZTfAYi1_N%&a`t>;Swr*e)~mr-bi7E}7y9&quPm21L2Uj3oZh?3b2u=I&Zr_jJn ze|PssMaRBF0j)p;aV>%*+|C?br-G%DDMzPECx`SvM0%S6yWrUtM2%y=svJp zRQI>t)LmTkI1HW*KUJn!pq$Jp08|aD`pMTGZ7e670p@EU_`}E}gFU!e^r0B=@ks4lTPMorEfOY#Xu80ZSa9krWt>Dg4c6Xc zN5%2oJG7%)H#e8;-rZb1aP)1bitB&akyCqrLh}szw1f_!jzTD9u8%d6jOd<))+%QK zq&NqoFVjO%P^5!0=%uFUt0s^%{et8RRYIJy6MvF&@`tjXQ-#GPf~lUE%mS@OwYPiU_P))V{6 z3KGG8;AGqzdchtgSiX{5P!tA|! z_lVZk)?-71gU4WH`$2(YnKU@P7(2cCXl6T)sVoH%^hTybAV3=I-OGOGC}ajK1YfkM z)eD!1n?Ca;@xta`i_M?^^ito6XTN%&YRN~sJ!MC(7qGi3dOS!D97=y?1Lh%^&XcR{jbeQh=Z=C@8Q9Bnn%Gm6Kp3-DI$a zMF0+%NCTNeOl5Y&cr}vkg%E046)<6?c!GtJ@gfP|99*w`#cqWWqx$_?Aa5hO3iGq0br(S zS4Bz5@hhWNDJbDlQ97ql-1ONmi=X`Sd;RvIeg835t(PcHC6u9A?QW_C&62TY6jmy!#4zwy${TKmMWV`1RYxyo;|Cf!usC($^*S{q_NI z;L%@+u3*8IQ^D%rXjamfG>oJ>hcMmhtzEmep|-ZBlD|d9B4W#9TaG{T%rkfLX3-LI zJ|chPG4A|8zUOx=NZ|XKfX{0Tm=geMJJFk0aAO2FR9Yc!`1IZ4hqu2yw4ncmf8Abj z(QT&g8C7jN39ztY$RbT66(#=gSpzs_xf_0Gz{5k=)Mma_g{zh-Yj7}T3)nwJWgx|p z#}kN5NhAPJgT)Tq2u506MyUaA>~AUJMHKPN{3fh2&gF^e{{CI%t3KE?xc`pf@7=e0 z`%mu6_4rf~k6I#Xih-V@+DDG$HGItk)3;NW+IE!01QfxSth@S}YZzdXlbrke`?dj$ zQ79)-RaGVZQYXSLCkwkwfx(^`P`<{2`Jx(wPo_%RH<8xaPC&$RX2hRGl0^a(kCD&I z-~U1J^AFs)s6Kr3wu3qIzNo5(AK+s>sa;xHO7O4*PIJlyfl2T|bih`1+oM={J}Xg? zlN_F%8y{@&n8`94JyY1DVP8>e*c&<$(|xBB!ZV->n_%{#nK)B5*ff>~lG5X^^i|JU zmZdg0U3>v_nO-v7srkniW0F? zIZFEcahGC~s^Z$K+|>#QOl*5O!?M64 z?Ra-QTu(sS8>bM%U5UVLcRC6yH8uwO8$v$<_`RG!rs^?s?AWZzXy;|+!|m65<3_z-5xIdpRrqmUCiIyz90PTX zCPgCQ6`j5LvwnFhr~0>HZ_W`dnFx5L>}!dn6JcVyLQbhsgmR|3;Hjdlq#Uq-mfubk zuO8aO3%MbB3;tEx|AVM(n0L1m6zc-eZm0b$37yA7H zKYJdF$77LjWU#llXInTNz8`HrhW3WCT_>qCEwifxxZ!gV_P>R$griWp@w(sfZI^{Y z`F{zf^M-=L!m{C^Ax}$7%PREckgEh-Dt@}JtWZfTf|9(Vy1M%2;*yd&$Uq)TvfyVY z$D(7SBg4bTW3lK@amb@M?_QV6J2l?7TBa4UQ+-K*(tjUvH0F*6&&TCbrUE0BWGP&W z4LP~FHM}w`n;V;CY&6^5q#yYP( zln1M6nXIG{jt|M3?i0F4(E-4^Xvdpt`dZ#m;1N}oix-JmE7ytAh9*&5J4Xcb3(-$a zB%%>9*m+!Zw;c3#?0TlIXyrq0sf$-|*)5 zv(kqXstJI6fFTkY6J@2P;>|bR{3h)8rc6co)RSAy?(Xj2;94T-76Jn4Mc;0lHEY&C zHO-&jICpM?C@CqCIoOmAg2l5e9{``<-`_u{t+n;mef##cb$56D7ta4p7TKqti=bS- zeEInLLXP#RUbwLNo<)lmiFhI*p7_Hbc10rLpXs{yQ;Qcb{=kx@%hamsDiMUze&mr~ zTTedu^btBZVr}K6W0_3RWCo$(Xr~_p@W}3 zc;LW&=+7qs{x*Qq2gUPWmt1;T32ugX_St9H^sg{3V;L^OWI)o~bXB(vF`S?G%;B;X z_i45)R7vPoLiJm*!cbzUDW|o2!O=b6T=DD=z8k#wZ*CWBZhEWC1x^J{R>xE=SRyK# zn?&EfBOAQAb>9Pz4J#>MPZo!RKPy2yI;**F@4pv@!)qJYUn17N?QcXyQ?u|u8<-{p z*)S!Q=4rg}!}80jME$CZ#hO3AP4pZ+B%b>2*9rr_-Sp38fvydEN|t?iO!K!ZR-9Tk z=?I9X%DnD5fKwJ#;3$i=?TU`i8syWQzwtV4+4XM`7JO-uo{?n%a!#%Y5A=%GmbN5o z;w{^B16YZgni?5Rbqu+*lnIPo5ZBY(+&n2Wiq4DOyLOIRju~SF)`>7Lg)jQ`wd>Zc zUbJYjjKZ_8QTU(G_+m^dOMngE7eWBJAXRyJxmdbvS>679`@Zyt-#>m^S9kZj(AF;Z zT#S;_x23?k6qbHKL1BT>&^S+r6%$*Zcw*Er%zOUq+Sk8(#fp{EKTauMx;ZHUaH%(x z!Fc2tua8`K(M2D*WFBjKx z<`>Jwwm>Q*3!`t(b3@UITD&f}VATaXcRu%{r?+jp6~pj%Xzs+T>SOW-n~D;SYyLJB z4ka!-9@BiuQ6=B(@mD;qglunK$;iBh{)6v%^gr)j!<%x^t?v|xvB;DZLiYv4f-9~Q zM|XX0ZorDyhPB`k+cY$(tyJC0v&UvF>Duw7Le-kH@n8Q{thnxG-e{48(3<1L5U25k zQ$i@9*_})Qqrf+O{0m~&>Ys?s|MlsWE4p|5&+f7n?;F(vZCVN#)G)d|acPigGkob@ zGL>ql^1-C>R%BGf-D^G_1Q%X>pdX$(3!DH|k>;A@05@73I&?@;Y z?b=J1E?p)qD;34@0$k^HX!_8r223TDB`~2bql#@YI1`0NOUkICZA&nX zYI%otm#zHwCF<@EKk?NsT{dU=YEj;>AWIdEqq*RamEm{4M|ks+BlE(Zymn34nx&|Q z*Gd#D?t1R-vY>CywIBaa(QwfQnQ}RosH3dlNhSd3KNkh?fq(g-_th`%+4b4o6>I)3 zq3Zn%&WKc9ItzBrX;nea)KZ;716si8+S^nbRA^2fmc{7b`qsVoJ_K-)E1C-zE_^R2 z)!T|dKL-Z}#M4i2`!a;|JDGV_SQpOP>Elw7_G zHUkWw!+D;9B^veneX@L#;0I`PA+Q(j+PU+emMvTU`U_UAg1{Du*T4SiVqMekf99E| zFMsygXLs;i^v^iifL6sFe zg-c>?ec}&BYisK_a1ZW53IA#4J$m z*S-GgdGJ3U#(1xVBI}v1Y)&7TG&SxkDf5$Y;;IupM_?h`76ASjSPu8_@vi2Vr_l zRk1m#@^lDKhMF_S!XenF3y4lz*i_m{m4KTtj%m|W+%{cPtBe;k@E#q9U>$NIuoSEg zN&7f$N09-rRw%vgS^Ogbp%jUDoI?7`E3Uky#}o^ z9>vA?VYIucv$Jy(sN0RFPM!RpjhA0hQUq{bwtju6udnwPuvnL%Z^w8HEs~_h84*3YY?bYI003VFfPRX8eeS{wFS-p@TA(d`|GpP=gKmHmR8rFVNJ~r_>L`Wf za2xJhzhQ%<&Bt0>#bb|cejdPm7utW8*N_e__uT0J5XS4*7^h!vd+Nz|oI2V0?%-zm0y>8qDj<(#~_BRKmZk1fOFhHy*rEQVE$ z)N4WrR&i{WmG%)DBxPykD9O3hJl@O_w4-rOfm2CgbG%xKs~_-(q~lxb(h?;N;mn`* zq(@sRC=@CR9RG$wq0d}$>18#!@L@+s!{XszJrp^7`0x$zi#EHK?Q9#`xqtKK%^d*W z!`Hmw&x%8#e6fDR#u~`kU9bcwzz8JGf9RnHcVHZ^_W68$Q(3$8 z@13##)`0{2JMr;>E3bT=ue_{WEMBs716+~62Lt*1%L+^@d`j3cXlxT2O7{s_q2_3Q zMLO_isyJJbX#mi8Qzq(}cHp8?Ogm7Ul9S`V1olzm{=BZi6URlQuUq6m3&VGu1RmNQ zmaF9yz<;s2f}FA8vEqeQ{cX3_E@=?UufA3!04Q+=;iB<>;hx^2; zH{L9cY<*0O9%y?@x4&YWrLa6sTEvu85L6~CyqTD&qa+e1T0^Ovm9!;T2xc>mYn@Ep zZ3DN%K3xKQrW?rXps$n-R18eG#qZGYs~0vex{1LV3OZ<>318`*pl6#2j_H);QP@a_ zVL6}Kwr$%j1%-tVZrpf9u&SzB%$wKrM)+~-V9B0zteu!pm+UC={{8{6d(W=jjg5_; zu1r)6JZDQ~|1`Wr4QC@2)5pNwkvpuHOb@;;uMeRVB# zy0xSgP5+L5cO)|Q=$<`$?kFiK{W@I$P-C%t#flGv^78%{JN3VGV9JgNG5GsW3V&;X zu(XiSLsi04+#vM)Swi&}2n{dQpYPByXYm_bN+;_)Wj(44(c(Qz;bbL@P%unt*o4+k zj*SQbs%jfXR;$LaiSD7$Dw+Xol*ap)=GjK&>YM&tCjS!gu_-6Gc>Mv9j73Dhqsa>( zI39e*B8F_VmT$d*9I^V%w}_J;|HRzVSkJnX!P-r!v2tqi2rPqju8Bz&(^iZr=)TL% z6T(i8!Tv@ky90)r02u5BLju(ElVAbuY?DgNt)j|2r(JArd2qVm0}2)%5yV@+X2NX%Z?B#dx|wM;8(_dt^!c>EFZ z%+G!<`r6v0{1(rt6BpimqnLl;#q_-<__OYoL|^7CY8J&c#iFSH)S6Sln%_&W#0~xs zR0LNtk;T{69lEb%cg1OCB{0XFi%Y*7)N01G?uW_cLmXf#X?~$Q$C57qsT95?3kO6p zDQTe%%kzbXhK5Z4D66pZHv)%%AMy_GD;iSR6Wd@b~zA55edHiGXz?%#->` ztHu|Vjq5YwnD%4Gj{Ts!yXSAp%gdyqaOIQzApPc;!Rjq(XlPtU@U#AS|NedL0M$2{ z2BAfCYnIPOWw|Y0yjYNmJO1c@gVtWVdi90!dPDj7Zv!~L>=u2zbRSbm*$Wx;*D^ty z6v^RkA!{9!Jh_glZLx4X$y!qx2Uk*)E$9oSUc&ZzlF_nIWuEXFUBVa%1Gz!8?-Pn+ zm{Pce6^M!Y2+t;4_#OLO|?)Gl6;;O4)P2&?mJx1KoB@hF7)#+=+7QCm|Re17lVO90{)#~*b< z5~+%vWFkp=eFW!iXVliUtn4cV-m$V8KzLnoNr?nk`>{5rV7^IOo~bklOezEyocx`% zm_Z`$pSk7dhrYIQ^@7*6(z)O0M%DU0&s6|k8F zuo5NtiSWW)Jt+ns`!`_-KPWLk9Vo>M)YzK~ON{RVc_I$qYow=7B)vubnq>xISaNIT z&4oJ`2O*A2@Y>^r_qL!F?r%RL{_ve2iox8_-sdY;-EAlynbAL)Q~TJGuI>N0_4_|u zJh!<~NF3oE$9xtsFO4n)ytP&}z}|85$aVqOY$%YXF7cxuBsy(FbH8 zC!0|6JJ7}5!$U(i2B5&0Qh=ptloJHf7Qv>)q=jNZ0CfYW?YY%D1Ybt`Ay}FU{!ZX^ z_jHHRhbL&QCk5#MLLSQ^1n$r4BYkE6nL^1zHxB`5o%5QSYN_;Hs?Cl5E!zWV7jote zthVUy>*Mt_;q!k@Conc;FcIxi_Hhn%cz6iZy@VB3&_{t4uM99VEA%wgqY61e+0s%Q z!O3&+&gYn#N7RqBy&>05l-5*Jj%{H=*iA0OXmy`vmo^=AA^L}fV4=)tQPB~ND_?5D z6K~rjdLG*ipFszp^MwK+v+hszg@iw^P;~4*2tkY|+iI8o)D(II;F4>=nu;fKta#qf z3p$@`?m60`7Oh?(63O_4w2u@P^vUPfg~t{_uNlu9({g)+yIQ9K7Lv$fF{L!>Q(HYr zWn;|EIKa%HvPwLAw00^gYfKFOu;1=u?f4!RN>;ki3Z!zGdRI2VO+TLdGa5;7lh&QV z$2~ecGAv3;OC)83HK?XiaNdtwOi3>pa7)eZ84sRJEH0N@E{+Q_%4~spMaQBrenX?_ zh31(7u9lV-NwEoDT0NI3Wa(=p92q?Z>tCDh4{~#TYKLF9B6*p7M;F@Y&^$nYvlI+>D#aFH#k%mvvyn-vKz!4UzCm^hxJYk1VNuL&t zd+c;)G!9J>ALN{dv^b68{Ns?CQ(8<~c-4vs)r?QtM`aLXnzhev;y!)tAQx0Fom;SA zK`<2%N>%<~|Hzrr4HQt)xTl_a>a6F74<}8&;fw(Qna>Itw|-O^4^Yvnr*6`C7FY_Z zhgK>*%FNJaDh*^v3mad!aAEvRk!hZbbemv1Qvi$o0G%GCw;mBOPLBUxx%{dOz46*IFMqC0#~HiRuc7%n0>8{h+W9dLeL5 z=v@A$O6{Vq|5qvaRCK|5#+>R54r!eZnUfewk9qc z;y$$1v3?2WI%!!`5lhvloMEyzk73y#eJwXYG}Q($6u6P$Sc8^q z5_U$Q*>q;coX)>mCM+zoY;K;>3k&CQa<^GQ$u<~SW}wH-i%xZ2Py``%A{G2O%?=1a zC$N*?Z;bxKCloD5T84Gb)qNSKBd36GD9L1E^c4lBOf}f?{H24tKIloti+SHb5&~W` zR;rsui4OoR%on1uS%{_vSHPxjkKv;cSj)a%P?tc_&V-^5_!TwR6j~ydFg;U^8QUx? zhSMLkwYtG0w}eacPDZsrFU*k=uwte41BY+P1*tABLZ3Am>74*<$-6Kz35Wz2tBz~F z5hW!oa<^o7M8xgXdbyb^1*uMaM<~859A6P*oyWys^tebE6VJyN*KLpWrmXk$fN7?x zf6@eyR?B@VG|TZ~oMH!IXHhz6S_OTxY*v%)F$c+Dk6UV%E%4%=r>d%IZVrT60uulm z92`7JpNjjti%{FPlW%1oGc+(Qhf8^#Hp59H8HL~mDZ(CIF91CaVV|+gN*lMLsI|3K z_LqJlt(;p6n`O(JJ$p_aTr8OiNsr2Ma)9$>=^-AUqvuHQ?%lKJ9}gZp_<)wcSy`sP*#{6cyBriF9VL=WT#7e0NvI4Gf0eO+s)vKrI>)EU&4NCh7P}zi% z>@KQ&3?R3Xs;AFTJ%io7X3o62Df)qSa|1%GSOh_TZlrNp*R%iDms_@j>i`r*dRG>S zv8rVYp!I#Jeq>W^?AtJ1NzFTC2rZ%rr;IBtIz6!h@ASZ*DR?8(OP-W6$ONXUrcwH{ z27gi&H7Or#Vj+MVNrg2yGBy^G(OahiXf3I3W}=>g$I>zP0Ywx>f}8#q+shJ_C5Tth zZ(`dFEb&}Q%!G_VmVnkPKxGvrZmF^6MOI*5y>!D;7ReEID$nFJG6H0CLtsRQ z4}((X6m9MI6z=d?rZ=v5dWQl9+xq&uZi>Ro@p-dbU7llhC4Rq9hyzEXl_MkV*UHcz z+?oaGS9#&o{ZJ&YNd=uE-rNJGs*kdo&?%ZYFSb^D092#saE-Dr!pv8v{9enrko9DGCP;& z!_ayI*z!JLtXAOf2ClZ@tnu52et%C)Tp#(BiORaZA;*(I%u-!@)&@vp_wI+)imTDK z%7(AwW5Sj*R)o_f%F^b1`dywwb#49R%=5S^>g%y2Q$$+vyv9QWwO| zaX;wo>3MfSe#%d-tg2c+Ffh=JefDub2BsLOaVIHfTJe;n&6l%542QDf8XGDrt8NGe zbH*oNyXg|QfP(ZMpLgM$hiYnPHTk?g_^q>Rpw#Zb_5VN8U5*pyou;>)X&q_78TD># zY?R~XR5Sf|ef``^SnM)1IEZs~aVC%T(kDSK!{_!HG_-rsH!%g7i=GeB|F#>UNE~V1tim+Dteg$BrE!)^M4jCLF*m|3=g*pG3d+P z*XJwQrdoz#sao=t1Ezh}fj^zcv?ftR247roK#)Iss_Wz%>H_s@C@%zhTJu+3U0n}7 z^UO0p2f)PH9ze`?C}f<*L~9iu9lfHdY5qHN^KzlwlAP{j0JwKi8Svbv6aT462`P(d zO_>jM{Zc2w`!w2nysD~tJ%L$MQ|mX9$$KHp>)YFp$L7qLBPUT$m0NVJJp0R%IIg0P zW4=6l_UxeP)E29px1O;^xD$jL>*?vatGlb~8yF)w*A)Q!7xd{jXm=OSJ9q9}Nqq@$ z9>e#vr0f@22j9~rpzljI06@Qc?YfIEp%rG|+FFke@7}%p?&%aPs8eS>WR0vX&UKx2 z`}72;7qd}$A3Q3=o;^Zz<&-?ynp5{}#gNaL7$C+-mE@)JmDznv_fZb+3&PF^NqxMd^PpIs{ZeQ7BnrU#BH{-0FS7T0_4mdN5 z#)*WpkjC_>sy)7LZu)&m7rxUz=ETh{FmMlt_WqZamcy6KpTDq@f;4w-V+cR}629T> zpoibrr=i(!o@;UJy>lBHOSnI+!=Zx*PPMeO-03VxEv*IHcdfOwm`T%_lbKBk>XII2 z1f#aZVzIA5`2V)Buvn1RHa9Q+bFP30;Jyd_=svqrQ$nDW|G9ACqIYxU1%e8I6I?6E z&bSLMou`GxZ*eG>f55r6G&VNrUXNFxjoF6|9e51m^j4gEv%A8cTLbJyh~0&@`SSU^ zZ!Ib+zGu#ydOmbUwvVxT2JXP8ryJp&bVvAjatyG1e1M`_*16KRb6rY~{Upr{M*+ya zpsxVMshrY>_ZKvOGHEMN^F{(UZVWd+>G&3$DPie~8aS9Y@AHA=*z9MY8(K$-+B7Fs zjANhkvs6-jI0{fc_dG!9FL(;)|17K#OtmaV1p|_E+{|;Rnq=j^DHFR)?Q$OFxp7(3 zS+7S<)`4)@6Dele?2-)X$ixyws-rl|%=eZZhazU^TSvZhdU)b$0>w<3u7~fk9 zUy+uJzaKx|j=zZ*_V?S)Iz#DwWc&1Y9cHibN-1q+(10PIarWL$yo zzp>vA2CLj659iz**ULkp&>iq;*O!&0roV;5qs+Co6%`fUuyNzY*i^aJvjUSRqGfUx zhBMEJzD-CRoEZqTkd&KP41j`1|N?A z%Ah;X@=$D#*WOdG=+5Osd;fdK&XLuOc`Tln0-0f)9iZ%o^iOexyIVk^kATAZ@}7IX zaPfzemKbC%fE7bj28_sBdgH@&Qg!1#R9O&=Aa&&a$1pK|-ix)3G!2L1KO`vMa zgTb6yMlMMQg)YdR6$BXuSMzft)39v++t=3{L_fX=fNNYmu(GO}DV&@7 z2l{Tp7#tmoM7CE~SGS_?c{pw{&kc%S&ZSp;exIa{LqmhG#3x!YwtrSuR(g_@c{+1S zU0|j^|09(!j>T*)tjt-Z=(yoVDjAefrkKrix+G4{^tCl-f46nlj1mN#Z50j+ak2}3 zT!#>SgF=i13%0eD&$+k9Tk@nx!cZB>I7|kgR273SlLXh7YAE$ z`Jn3w3aZCOlZ9kVz2f2V%wg|C3 z-p9#{KBv!NboTc(W6H`F)}jzKJ+ih=Y9elB9xb(i{CE*XfLqE>3Nvr zOG<)5kBp9pp6;%}BS((hnM|7ZdOZ3+%3=W_^R$wUxaTJo=VDx(s+E@VxCa)p4F=&0 z6_pi@dAT8(&g1lTIsw;&kE=Z+FB&&1ssGR9FFf0VqEv&;G(Srxu zO6$LR(p&xrIt@o5k;I^L&7!1}aMy)LHCW(4nC@#&fj(`H^7yz=_D09J)`!KK;V2H# zAq*_QOL$aUI|juu5KfIrCcogZ0~|xe@C)fpdNc$A1@!`J?&y`Pbza z6#8YMJb>Wy`6pa&EEF&a^&E5X;%}K>Ggf?sg&IkidTonZ`0)h|oHM#Qn2;AC;>S;ODYXxZx$*GV+rn0NY2S(b(OQaQMyW z)1|q2p-X*UZ-t_$9)}u5!6I7G?q>9rt6lsiJwN+mHa$Zyq-dcdToS~@g=zh&|G<{K z6>sopN)ArOJM7`44|ky`dR~G{g``UMO+)pKd91|OG&7M4+U9ZA_<^a>l7{MuBouuJ z@1xRp#okI%E_iMv;Y?$23@$T>^BV&L0~WN7<@mT(roeS|b&=*#=p^k%chH#OHFSOG zc%bU1CjylZ2Fz$pz&5HpX1p+9h70Ik#I&4|gz6uN3GGxw^`EeW8rMuywXGP}CyH~8 zB7zeAF!}rvUMB>B;MaT9+-JAsuee566+Xhva+6UF%mc+1jHAFDzMfbQbhDEwRWBFSZwpz%#AOV_qKwVRJOG&DT! zmfpDnpA9tGf(>cw*0479N4U-(aS}TyV+F=D==g?X_^u0=&9N9?X&~Fie#GPP2^BSv zoj&-TpLUDHpMO3gm)uC-+%iDdYU1w*&Ut-BWp$-0(q9TSbw+~8U zANqC|#+h|)#hmBs%p4lTcl|Ogk`}Q}QUBbV_$Wr^Q@Lsd#&a)#ZKaPF_jMy#W5boR1#W^)d#)odgDp(oeZL;pr?GcFt7RrHcTDK~3xRDt6q`MhsPtsxTg$ z$c2F!U%?G>X=@CW%BcaCt%Ci5(1b1FQ@ zkzrCM*(_U;Ryttr^Gj0Wd(Kw{)zwrUiZS70(;AguBGD!sIomMh|x}7 z$H9XK(`oF;ym^gZC@-)4j1EiBGD3j+V~~l5ARouv)dU>HGUU9*+jgIOLb+u%57&!@ zVklm@a^>6TFB7b+9p>_u>8q}%gOfq5^d&g6DKzHOajy3C<6iDfpCYPi@xquof$zZd z2^VW-lrWk8tjTe$Y$&8gwxjuMXOIj@91B`bq@_#^8c-f|8;@Z`!m;TyxDeV!Gk?^KD~FhqTemm>mPA@Pq#T-j9@&l;`q} z6&IHlE?&I&dl>%>09n$_3%bg~wNh?yh0$yJyQIl{>_KB=DEbi95arW<3hGV3hx}7O-ad( zwClC}sP^>PAsJf-uI=N2K=8BvKoE3775N2)>oBH2!RuX+yMA{C1j?rSJP}f9j)|M- z=l5&YtogUn(z4s#xtpS7&Y`;sZO`%4gWSxUE6G3tEeToy>w;io(I}h5i z(&=%Qb|;Jl!{B(Oo-m#9+(@VL!*(B#n{m7XYGtM^;;dv&XG&9SnaPw%8z~^CIZd^k z#`(T63hF*DWO7-i_pXf_H*P3a)vGnlBO|ayMa6HzJzE0z|HBx%2l&LXbeVHy%c0aO z0nASn6ck>~6bEZW=&y#uqrZc1ejoFRQvq`-8hbtfGu>*A3yB-8cd19V)yU4ZN?T;l zxZ5waO}DRf({I$4InYi;6r-~Xwp$@=Dd;_lWs{q?yFnGi7nY;9Qea(J< zu-SHs)4&tM_O*jQxKjvYJR24m8_b?er%_KgdCWlnBBUx0Zg0a5-4 zAbPpMKHdJ>FLT@HI_>n;7@zZEBWT>z##Am4(-80@--5qC1L!{H_Xienu|>sMCW2N} zRke)BDw#~uc>;C38}#)q!!SQjmy7N^KeN3SzzGY>$qalH-_HQHBE04Rd`+XHqeY2CLIr3UOlScxTj0BP zF~~=&oW9`KYwDU`Z6|kTo7rZzEb)VxA(+`_wi#f~Y%|-;HjVB73orm`T~JCU>#6zx O0000dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> } div.fichecenter { + /* margin-top: 10px; */ width: 100%; clear: both; /* This is to have div fichecenter that are true rectangles */ } @@ -1737,7 +1738,7 @@ div.vmenu, td.vmenu { .vmenu { width: 190px; - margin-left: 4px; + margin-left: 6px; display: none; @@ -1953,10 +1954,11 @@ img.toolbarbutton { /* ============================================================================== */ div.tabs { text-align: ; - margin-left: 6px !important; - margin-right: 6px !important; + padding-left: 6px !important; + padding-right: 6px !important; clear:both; height:100%; + /* background-image: linear-gradient(to top,#f6f6f6 0,#fff 8px); */ } div.tabsElem { margin-top: 1px; @@ -2018,7 +2020,7 @@ a.tabTitle { a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { font-family: ; - padding: 8px 9px 8px; + padding: 12px 9px 12px; margin: 0em 0.2em; text-decoration: none; white-space: nowrap; @@ -2027,11 +2029,6 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { border-left: 1px solid transparent; border-top: 1px solid transparent; border-bottom: 0px !important; - /* - -moz-border-radius:4px 4px 0 0; - -webkit-border-radius: 4px 4px 0 0; - border-radius: 4px 4px 0 0; - */ background-image: none !important; } @@ -3036,9 +3033,12 @@ td.legendLabel { padding: 2px 2px 2px 0 !important; } div.titre { font-family: ; - font-weight: bold; + font-size: 14px; + /* font-weight: bold; */ color: rgb(); text-decoration: none; + padding-top: 5px; + padding-bottom: 5px; /* text-shadow: 1px 1px 2px #FFFFFF; */ } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6513210a1a9..52fb9d3ab1a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -241,7 +241,7 @@ body { color: rgb(); font-size: px; - line-height: 130%; + line-height: 1.3; font-family: ; margin-top: 0; margin-bottom: 0; @@ -3146,9 +3146,12 @@ td.legendLabel { padding: 2px 2px 2px 0 !important; } div.titre { font-family: ; - font-weight: bold; + font-size: 14px; + /* font-weight: bold; */ color: rgb(); text-decoration: none; + padding-top: 5px; + padding-bottom: 5px; /* text-shadow: 1px 1px 2px #FFFFFF; */ dol_optimize_smallscreen)?'':'margin-top: 4px;'); ?> } diff --git a/htdocs/user/note.php b/htdocs/user/note.php index ae685391299..ca9f821d14c 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -52,6 +52,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('usercard','globalcard')); + /******************************************************************************/ /* Actions */ /******************************************************************************/ diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index f7acc3609c7..e59e26efd0b 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -191,15 +191,6 @@ $conf_css = $themepath."?lang=".$langs->defaultlang; $jquerytheme = 'smoothness'; if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; -if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png')) -{ - $login_background = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'; -} -else -{ - $login_background = DOL_URL_ROOT.'/theme/login_background.png'; -} - if (! $username) $focus_element = 'username'; else $focus_element = 'password'; From cea835744c61486f2cadafec2e589fe6578fc628 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 23:06:46 +0200 Subject: [PATCH 164/172] Look and feel v6 --- htdocs/theme/md/style.css.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 52fb9d3ab1a..7818422d192 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1137,6 +1137,9 @@ table.noborder tr.liste_titre td { .pictoedit, .pictowarning, .pictodelete { vertical-align: text-bottom; } +img.hideonsmartphone.pictoactionview { + vertical-align: bottom; +} .colorthumb { padding-left: 1px !important; padding-right: 1px; @@ -4680,7 +4683,7 @@ border-top-right-radius: 6px; } .mainmenuaspan { /*display: none;*/ - font-size: 10px; + font-size: 12px; } .topmenuimage { background-size: 26px auto; From 56140ae5729df78af81b174631f8156e85c5c94e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 01:09:22 +0200 Subject: [PATCH 165/172] Work on default focus --- build/debian/README.howto | 9 ++-- htdocs/admin/defaultvalues.php | 89 +++++++++++++++++++++------------- htdocs/core/lib/admin.lib.php | 5 ++ htdocs/langs/en_US/admin.lang | 7 +-- 4 files changed, 71 insertions(+), 39 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 399c4f07a1f..e040cd6dced 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -152,7 +152,7 @@ tag 729538 -moreinfo -##### Testing a package into unstable env +##### Testing a package into a chroot environment Check you have a mysql server available from another interface than "localhost". Set line in /etc/mysql/my.cnf if required and restart mysql @@ -160,9 +160,11 @@ Set line in /etc/mysql/my.cnf if required and restart mysql [mysqld] bind-address = * -Create a chroot called "unstable-amd64-sbuild". +Create a chroot called "jessie" or "unstable". Chroot env is stored into /srv/chroot directory. > sudo sbuild-createchroot --keyring=unstable /srv/chroot/unstable http://ftp.uk.debian.org/debian +or +> sudo sbuild-createchroot jessie /srv/chroot/jessie http://ftp.uk.debian.org/debian Pour lister les env chroot > schroot -l @@ -170,8 +172,9 @@ or > ls /srv/chroot Puis pour se connecter et préparer l'environnement -> schroot -c name_of_chroot +> schroot -c name_of_chroot (exemple schroot -c unstable-amd64-sbuild) > cat /etc/debian_chroot to check which debian branch we are into +> apt-get install vi > vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok) > apt-get update > apt-get upgrade diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 8a9bd4f209b..ec4c5fd4605 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -37,7 +37,7 @@ if (!$user->admin) accessforbidden(); $id=GETPOST('rowid','int'); $action=GETPOST('action','alpha'); -$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder' +$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -210,6 +210,10 @@ if ($mode == 'sortorder') { print info_admin($langs->trans("WarningSettingSortOrder")).'
    '; } +if ($mode == 'focus') +{ + print info_admin($langs->trans("FeatureNotYetAvailable")).'
    '; +} print ''; print ''; @@ -217,11 +221,13 @@ print ''; print '
    '; +// Page $texthelp=$langs->trans("PageUrlForDefaultValues"); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); +// Field $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') { @@ -233,26 +239,32 @@ else $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); } print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); -if ($mode != 'sortorder') +// Value +if ($mode != 'focus') { - $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
    '; - // See list into GETPOST - $texthelp.='__USERID__
    '; - $texthelp.='__SUPERVISORID__
    '; - $texthelp.='__MYCOUNTRYID__
    '; - $texthelp.='__DAY__
    '; - $texthelp.='__MONTH__
    '; - $texthelp.='__YEAR__
    '; - if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
    '; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); + if ($mode != 'sortorder') + { + $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
    '; + // See list into GETPOST + $texthelp.='__USERID__
    '; + $texthelp.='__SUPERVISORID__
    '; + $texthelp.='__MYCOUNTRYID__
    '; + $texthelp.='__DAY__
    '; + $texthelp.='__MONTH__
    '; + $texthelp.='__YEAR__
    '; + if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
    '; + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); + } + else + { + $texthelp='ASC or DESC'; + $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); + } + print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); } -else -{ - $texthelp='ASC or DESC'; - $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); -} -print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); +// Entity if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,page','',$param,'',$sortfield,$sortorder); +// Actions print ''; print "\n"; @@ -261,15 +273,21 @@ print "\n"; print "\n"; print ''; +// Page print ''."\n"; +// Field print ''; -print ''; +// Value +if ($mode != 'focus') +{ + print ''; +} // Limit to superadmin if (! empty($conf->multicompany->enabled) && !$user->entity) { @@ -311,28 +329,33 @@ if ($result) print ''; + // Page print ''."\n"; - // Key + // Field print ''."\n"; // Value - print ''; - + if ($mode != 'focus') + { + print ''; + } + + // Actions print ''; - + print "\n"; print "\n"; $i++; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 2a734b5f161..4beb49107d2 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -624,6 +624,11 @@ function defaultvalues_prepare_head() $head[$h][2] = 'sortorder'; $h++; + $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=focus"; + $head[$h][1] = $langs->trans("DefaultFocus"); + $head[$h][2] = 'focus'; + $h++; + /*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey"; $head[$h][1] = $langs->trans("TranslationKeySearch"); $head[$h][2] = 'searchkey'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4b56ef00ae1..14131bddd2c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1352,9 +1352,10 @@ CacheByClient=Cache by browser CompressionOfResources=Compression of HTTP responses TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record. -DefaultCreateForm=Create forms -DefaultSearchFilters=Search filters -DefaultSortOrder=Sort orders +DefaultCreateForm=Default values for new objects +DefaultSearchFilters=Default search filters +DefaultSortOrder=Default sort orders +DefaultFocus=Default focus fields ##### Products ##### ProductSetup=Products module setup ServiceSetup=Services module setup From 9b90e7aa095bff665604d541ef14976f3ae605a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 01:41:56 +0200 Subject: [PATCH 166/172] Minor fix --- build/debian/README.howto | 5 +++-- htdocs/bookmarks/bookmarks.lib.php | 2 +- htdocs/theme/eldy/style.css.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index e040cd6dced..c94309ec2ef 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -174,7 +174,7 @@ or Puis pour se connecter et préparer l'environnement > schroot -c name_of_chroot (exemple schroot -c unstable-amd64-sbuild) > cat /etc/debian_chroot to check which debian branch we are into -> apt-get install vi +> apt-get install vi dialog > vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok) > apt-get update > apt-get upgrade @@ -404,6 +404,7 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. After discussion with ..., it appears that security holes are enough to request this unblock request." + Use this to request an full update of a stable package reportbug -B debian --smtphost=smtp.gmail.com:587 --smtpuser=xxxx --smtppasswd=yyyy --tls @@ -434,7 +435,7 @@ Use this to ask to apply patches on a stable version. reportbug -B debian --smtphost=smtp.gmail.com:587 --smtpuser=xxxx --smtppasswd=yyyy --tls Choose package "release.debian.org" -Then usertag "jessie-pu" +Then usertag "jessie-pu" (if tags is not available in list, choose another one, and change it later into email content text) Then name of package "dolibarr" Fill message, for example: "Please unblock package dolibarr diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index d84713d1e62..26089c3d07c 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -62,7 +62,7 @@ function printBookmarksList($aDb, $aLangs) */ $ret.= ''."\n"; - $ret.= ''; + $ret.= ''; $ret.= '
    '; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
    '.$langs->trans("RefTask").''.$langs->trans("LabelTask").'
    '; -$searchpitco=$form->showFilterAndCheckAddButtons(0); -print $searchpitco; -print '
    '; print ''; print ''; print ''; print ''; -print ''; -print ''; + print ''; + print '
    '; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; else print ''; print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; else print ''; print ''; - /*print ''; - print ''; - print ''; - print ''; - */ - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; - else print ''; - print ''; + /*print ''; + print ''; + print ''; + print ''; + */ + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + else print ''; + print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { @@ -349,7 +372,7 @@ if ($result) print ''; } print '
    "; @@ -180,7 +180,6 @@ print ''; print ""; $i=1; -$var=true; while ($i <= $MAXAGENDA) { $key=$i; @@ -189,7 +188,7 @@ while ($i <= $MAXAGENDA) $offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; $color='AGENDA_EXT_COLOR_'.$id.'_'.$key; - + print ''; // Nb print '"; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c9551cdbc23..9f36bc91e31 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -50,7 +50,8 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); + $object->getrights(); } /* diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3255dc676cf..675f5748842 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1140,7 +1140,7 @@ else if ($id > 0) { - $object->fetch($id); + $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 5299f348431..1500a3be55c 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -83,7 +83,8 @@ llxHeader("","ClickToDial"); if ($id > 0) { $object = new User($db); - $object->fetch($id); + $object->fetch($id, '', '', 1); + $object->getrights(); $object->fetch_clicktodial(); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index a8d5000e809..8b055979992 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -86,7 +86,7 @@ if (! $sortfield) $sortfield="name"; $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); $object->getrights(); $entitytouseforuserdir = $object->entity; if (empty($entitytouseforuserdir)) $entitytouseforuserdir=1; diff --git a/htdocs/user/info.php b/htdocs/user/info.php index 86bff7147ff..d20624063f2 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -34,7 +34,7 @@ $id = GETPOST('id','int'); $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); $object->getrights(); } diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 0f0cc6b4ed7..252ed9f82b4 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -42,7 +42,7 @@ if ($user->id == $id) $feature2=''; // A user can always read its own card $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array diff --git a/htdocs/user/note.php b/htdocs/user/note.php index ca9f821d14c..2844676a465 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -36,7 +36,7 @@ $langs->load("bills"); $langs->load("users"); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // If user is not user read and no permission to read other users, we stop @@ -53,9 +53,9 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $hookmanager->initHooks(array('usercard','globalcard')); -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ $parameters=array('id'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -76,9 +76,9 @@ if (empty($reshook)) { } -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * View + */ llxHeader(); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 4f47578f543..2b7c31d75df 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -122,7 +122,8 @@ if ($action == 'delete') $form = new Form($db); $object = new User($db); -$result=$object->fetch($id); +$result=$object->fetch($id, '', '', 1); +$object->getrights(); $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notification"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notification"); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index e84cfe09ca8..b40c79f783e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -68,7 +68,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id <> $id && ! $canreaduser) accessforbidden(); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array From d948447600f7d6ab6fd546b6c091bb6bf7b3dd78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 17:08:38 +0200 Subject: [PATCH 169/172] Add button to disable all personalized default values in one click. --- htdocs/admin/defaultvalues.php | 22 ++++++++++++++++++++++ htdocs/admin/modules.php | 20 ++++++++++++-------- htdocs/admin/stock.php | 1 + htdocs/core/lib/functions.lib.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/product/traduction.php | 7 +++---- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index ec4c5fd4605..dd37e4987e5 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -84,6 +84,11 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_array_options=array(); } +if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); +} if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { @@ -185,6 +190,23 @@ print load_fiche_titre($langs->trans("DefaultValues"),'','title_setup'); print $langs->trans("DefaultValuesDesc")."
    \n"; print "
    \n"; +print $langs->trans("EnableDefaultValues").' '; +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) +{ + // Button off, click to enable + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; +} +else +{ + // Button on, click to disable + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; +} +print "

    \n"; + $param='&mode='.$mode; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c47586b2b2a..88944ee589a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -640,7 +640,8 @@ if ($mode == 'common') { $disableSetup = 0; - print '
    '."\n"; - // Config link + // Link config if (! empty($objMod->config_page_url) && !$disableSetup) { if (is_array($objMod->config_page_url)) { - print ''; + print ''; } else { - print ''; + print ''; } } else { - print ''; + print ''; } } else // Module not yet activated { - print '\n"; - print ''; + + // Link config + print ''; } print "\n"; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index c8204f213c2..72ff0f17a1b 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -149,6 +149,7 @@ if (! empty($conf->productbatch->enabled)) //if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) //{ print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); +print '
    '; //} // Title rule for stock decrease diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 262204b9f72..e3c6cb7d5cd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -260,7 +260,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) global $conf; // Management of default values - if (! isset($_GET['sortfield']) && empty($conf->global->MAIN_DISABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on + if (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on { if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 14131bddd2c..8425aa2c4c6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -431,6 +431,7 @@ TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=
    For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
    For page that list thirdparties, it is %s +EnableDefaultValues=Enable usage of personalized default values GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index b5f4b8b34ae..03f7e1c54ac 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -277,16 +277,14 @@ if ($action == 'edit') } else if ($action != 'add') { - //if ($cnt_trans) print '
    '; - if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { $s=picto_from_langcode($key); - //print ''; + + print '
    '; print '
    '; print '
    '.$langs->trans("Color").'
    '.$langs->trans("AgendaExtNb",$key)."'; + // Link enable/disabme + print ''; if (! empty($arrayofwarnings[$modName])) { print ''."\n"; @@ -662,12 +663,12 @@ if ($mode == 'common') } print ''; + print ''; $i=0; foreach ($objMod->config_page_url as $page) { @@ -693,22 +694,23 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''; + // Link enable/disable + print ''; if (! empty($objMod->always_enabled)) { // Should never happened @@ -754,7 +756,9 @@ if ($mode == 'common') print "\n"; } print "'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'
    '; print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; - //print '
    '; print ''; @@ -296,6 +294,7 @@ else if ($action != 'add') print ''; } print '
    '.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
    '.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
    '; + print '
    '; } } if (! $cnt_trans && $action != 'add') print '
    '. $langs->trans('NoTranslation').'
    '; From 910a92516711a006ad0f7424b4d3f44ce2de7594 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 20:43:14 +0200 Subject: [PATCH 170/172] NEW Add last activation author and ip of modules --- htdocs/admin/modulehelp.php | 18 ++++++++ htdocs/admin/modules.php | 6 +-- htdocs/admin/user.php | 4 +- htdocs/admin/usergroup.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 42 ++++++++++++++++-- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/societe/admin/contact_extrafields.php | 2 +- htdocs/societe/admin/societe.php | 2 +- htdocs/societe/admin/societe_extrafields.php | 2 +- htdocs/theme/dolibarr_logo.png | Bin 14646 -> 10289 bytes htdocs/theme/eldy/style.css.php | 10 ++++- htdocs/user/admin/group_extrafields.php | 2 +- htdocs/user/admin/user_extrafields.php | 2 +- 19 files changed, 84 insertions(+), 24 deletions(-) mode change 100644 => 100755 htdocs/theme/dolibarr_logo.png diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 94bfa8e05bb..d318566ff61 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -330,6 +330,24 @@ if ($mode == 'desc') else $text.=$langs->trans("Disabled"); $text.='
    '; + $tmp = $objMod->getLastActivationInfo(); + $authorid = $tmp['authorid']; + if ($authorid > 0) + { + $tmpuser = new User($db); + $tmpuser->fetch($authorid); + $text.=''.$langs->trans("LastActivationAuthor").': '; + $text.= $tmpuser->getNomUrl(1); + $text.='
    '; + } + $ip = $tmp['ip']; + if ($ip) + { + $text.=''.$langs->trans("LastActivationIP").': '; + $text.= $ip; + $text.='
    '; + } + $moduledesclong=$objMod->getDescLong(); if ($moduledesclong) $text.='

    '.$moduledesclong.'
    '; } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 88944ee589a..433508be908 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -402,9 +402,9 @@ if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouM print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup'); // Start to show page -if ($mode=='common') print $langs->trans("ModulesDesc")."
    \n"; -if ($mode=='marketplace') print $langs->trans("ModulesMarketPlaceDesc")."
    \n"; -if ($mode=='deploy') print $langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
    \n"; +if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
    \n"; +if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
    \n"; +if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
    \n"; $h = 0; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 42feea8f8ec..0c7574b7ec4 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -167,7 +167,7 @@ print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup'); $head=user_admin_prepare_head(); -dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), 0, 'user'); +dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print ''; print ''; @@ -205,7 +205,7 @@ print ''; print '
    '; - +print '
    '; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index db5ef3cbf59..4642e6d3183 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -151,7 +151,7 @@ print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup'); $head=user_admin_prepare_head(); -dol_fiche_head($head,'usergroupcard', $langs->trans("MenuUsersAndGroups"), 0, 'user'); +dol_fiche_head($head,'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user'); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index fe582d56656..0b4c3c239f9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1057,7 +1057,7 @@ else // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); - dol_fiche_head(''); + dol_fiche_head('', '', '', -1); print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 4beb49107d2..2016807efe9 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -812,7 +812,7 @@ function activateModule($value,$withdeps=1) return $ret; } - $result=$objMod->init(); + $result=$objMod->init(); // Enable module if ($result <= 0) { $ret['errors'][]=$objMod->error; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index e95359e5683..d2d8e36b8ca 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -269,7 +269,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4c873830948..b51292a0bb8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -478,7 +478,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 48ce35f1532..d0559268c52 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -795,6 +795,37 @@ class DolibarrModules // Can not be abstract, because we need to insta } + /** + * Gives the last author of activation + * + * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) + */ + function getLastActivationInfo() + { + global $conf; + + $sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->const_name."'"; + $sql.= " AND entity IN (0, ".$conf->entity.")"; + + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) $err++; + else + { + $obj=$this->db->fetch_object($resql); + $tmp=array(); + if ($obj->note) + { + $tmp=json_decode($obj->note, true); + } + if ($obj) return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + } + + return array(); + } + + /** * Insert constants for module activation * @@ -802,7 +833,7 @@ class DolibarrModules // Can not be abstract, because we need to insta */ function _active() { - global $conf; + global $conf, $user; $err = 0; @@ -817,10 +848,13 @@ class DolibarrModules // Can not be abstract, because we need to insta $resql=$this->db->query($sql); if (! $resql) $err++; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible,entity) VALUES"; + $note=json_encode(array('authorid'=>$user->id, 'ip'=>$_SERVER['REMOTE_ADDR'])); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES"; $sql.= " (".$this->db->encrypt($this->const_name,1); - $sql.= ",".$this->db->encrypt('1',1); - $sql.= ",0,".$entity.")"; + $sql.= ", ".$this->db->encrypt('1',1); + $sql.= ", 0, ".$entity; + $sql.= ", '".$this->db->escape($note)."')"; dol_syslog(get_class($this)."::_active", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 1245041d98a..81e3936d300 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -258,7 +258,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { -
    '; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 29dcc413221..947d99af545 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4938,25 +4938,33 @@ abstract class CommonObject if(!empty($id)) $sql.= ' WHERE rowid = '.$id; else $sql.= ' WHERE ref = \''.$this->quote($ref).'\''; - + $res = $this->db->query($sql); - if($obj = $this->db->fetch_object($res)) + if ($res) { - $this->id = $id; - $this->set_vars_by_db($obj); - - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); - - return $this->id; + if ($obj = $this->db->fetch_object($res)) + { + $this->id = $id; + $this->set_vars_by_db($obj); + + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); + + return $this->id; + } + else + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } } else { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; } - } /** diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 021213594f7..1456fb991c2 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -106,14 +106,12 @@ class CoreObject extends CommonObject */ public function fetch($id, $loadChild = true) { - $res = $this->fetchCommon($id); if($res>0) { if ($loadChild) $this->fetchChild(); } return $res; - } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b51292a0bb8..b7a372e50bd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1265,7 +1265,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Inventory - if ($conf->global->MAIN_LEVEL_FEATURES >= 2) + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($conf->stock->enabled)) { diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e80966afb81..be6817062b6 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -117,32 +117,37 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; - if ($conf->global->MAIN_LEVEL_FEATURES >= 2) { + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $this->rights[5][0] = 1006; + $this->rights[5][0] = 1011; $this->rights[5][1] = 'inventoryReadPermission'; // Permission label $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][0] = 1007; + $this->rights[6][0] = 1012; $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1008; + $this->rights[7][0] = 1013; $this->rights[7][1] = 'inventoryWritePermission'; // Permission label $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1009; - $this->rights[7][1] = 'inventoryValidatePermission'; // Permission label - $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][0] = 1014; + $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[8][3] = 0; // Permission by default for new user (0/1) + $this->rights[8][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1010; - $this->rights[7][1] = 'inventoryChangePMPPermission'; // Permission label - $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][0] = 1015; + $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[9][3] = 0; // Permission by default for new user (0/1) + $this->rights[9][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql index b3e2001f9c3..926a05a738e 100644 --- a/htdocs/install/mysql/tables/llx_fichinter.sql +++ b/htdocs/install/mysql/tables/llx_fichinter.sql @@ -43,5 +43,4 @@ create table llx_fichinter note_public text, model_pdf varchar(255), extraparams varchar(255) -- for stock other parameters with json format - )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_inventory.sql b/htdocs/install/mysql/tables/llx_inventory.sql index f906699f5dd..ce1a2c93744 100644 --- a/htdocs/install/mysql/tables/llx_inventory.sql +++ b/htdocs/install/mysql/tables/llx_inventory.sql @@ -1,6 +1,6 @@ -- =================================================================== --- Copyright (C) 2012 Laurent Destailleur --- Copyright (C) 2017 ATM Consulting +-- Copyright (C) 2017 Laurent Destailleur +-- Copyright (C) 2017 ATM Consulting -- -- 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 @@ -19,13 +19,18 @@ CREATE TABLE llx_inventory ( -rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec datetime DEFAULT NULL, -tms timestamp, -fk_warehouse integer DEFAULT 0, -entity integer DEFAULT 0, -status integer DEFAULT 0, -title varchar(255) NOT NULL, -date_inventory datetime DEFAULT NULL + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0, + ref varchar(48), + datec datetime DEFAULT NULL, + tms timestamp, + fk_user_author integer, -- user making creation + fk_user_modif integer, -- user making last change + fk_user_valid integer, -- valideur de la fiche + fk_warehouse integer DEFAULT 0, + status integer DEFAULT 0, + title varchar(255) NOT NULL, + date_inventory datetime DEFAULT NULL, + import_key varchar(14) -- import key ) ENGINE=InnoDB; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 34e79da8a69..e47891a6d08 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -361,9 +361,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; echo ''; @@ -373,8 +373,14 @@ if ($action == 'create') if ($action == 'view' || $action == 'edit' || empty($action)) { $object = new Inventory($db); - $object->fetch($id); - + $result = $object->fetch($id); + if ($result < 0) dol_print_error($db, $object->error, $object->errors); + + $warehouse = new Entrepot($db); + $warehouse->fetch($object->fk_warehouse); + + + if($action == 'changePMP') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ApplyNewPMP'), $langs->trans('ConfirmApplyNewPMP', $object->getTitle()), 'confirm_changePMP', array(),'no',1); @@ -396,18 +402,17 @@ if ($action == 'view' || $action == 'edit' || empty($action)) print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('RegulateStock'),$langs->trans('ConfirmRegulateStock',$object->getTitle()),'confirm_regulate',array(),'no',1); } - $warehouse = new Entrepot($db); - $warehouse->fetch($object->fk_warehouse); - print dol_get_fiche_head(inventoryPrepareHead($object, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action)); $lines = array(); card_line($object, $lines, $action); - print ''.$langs->trans('inventoryOnDate')." ".$object->getDate('date_inventory').'

    '; + print $langs->trans('Ref')." ".$object->ref.'
    '; + print $langs->trans('Date')." ".$object->getDate('date_inventory').'

    '; $objectTPL = array( - 'id'=> $object->id + 'id'=> $object->id + ,'ref'=> $object->ref ,'date_cre' => $object->getDate('date_cre', 'd/m/Y') ,'date_maj' => $object->getDate('date_maj', 'd/m/Y H:i') ,'fk_warehouse' => $object->fk_warehouse @@ -608,8 +613,8 @@ function _headerList($view) ?>
    - - + + barcode->enabled)) { ?> diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 93bbb38f6e7..8cb1f56eb9d 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -69,6 +69,7 @@ class Inventory extends CoreObject */ protected $fields=array( 'fk_warehouse'=>array('type'=>'integer','index'=>true) + ,'ref'=>array('type'=>'string','index'=>true) ,'entity'=>array('type'=>'integer','index'=>true) ,'status'=>array('type'=>'integer','index'=>true) ,'date_inventory'=>array('type'=>'date') @@ -113,7 +114,8 @@ class Inventory extends CoreObject if(!$loadChild) $this->withChild = false; $res = parent::fetch($id, $loadChild); - if($res > 0) + + if ($res > 0) { $this->sortDet(); $this->amount = 0; diff --git a/htdocs/product/inventory/tpl/inventory.tpl.php b/htdocs/product/inventory/tpl/inventory.tpl.php index 2a1c3bc3ee4..05de0f4c002 100644 --- a/htdocs/product/inventory/tpl/inventory.tpl.php +++ b/htdocs/product/inventory/tpl/inventory.tpl.php @@ -80,7 +80,7 @@ - +
    @@ -92,7 +92,7 @@ -
      Produittrans('Warehouse'); ?>trans('Product'); ?>trans('Warehouse'); ?> trans('Barcode'); ?>
    +