From a7813c37a1dee3b5ba8d2e4da451e0f16e96f519 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Dec 2016 12:36:00 +0100 Subject: [PATCH 001/505] 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 b8284447fd0149d574ded0dd073b4426376e248c Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 12 Dec 2016 15:19:47 +0100 Subject: [PATCH 002/505] API can receive documents --- htdocs/api/class/api.class.php | 41 ++--- htdocs/api/class/api_documents.class.php | 143 ++++++++++++++++++ htdocs/api/index.php | 12 +- test/phpunit/RestAPIDocumentTest.php | 183 +++++++++++++++++++++++ 4 files changed, 354 insertions(+), 25 deletions(-) create mode 100644 htdocs/api/class/api_documents.class.php create mode 100644 test/phpunit/RestAPIDocumentTest.php diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5ffae225df1..ed97968e502 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -19,6 +19,7 @@ use Luracast\Restler\Restler; use Luracast\Restler\RestException; use Luracast\Restler\Defaults; +use Luracast\Restler\Format\UploadFormat; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -47,14 +48,14 @@ class DolibarrApi function __construct($db, $cachedir='') { global $conf; - + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; Defaults::$cacheDirectory = $cachedir; - + $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode); - + $this->r->setAPIVersion(1); } @@ -86,20 +87,20 @@ class DolibarrApi // Remove $db object property for object unset($object->db); - + // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses unset($object->linkedObjects); - + unset($object->lignes); // should be ->lines unset($object->oldline); - + unset($object->error); unset($object->errors); - + unset($object->ref_previous); unset($object->ref_next); unset($object->ref_int); - + unset($object->projet); // Should be fk_project unset($object->project); // Should be fk_project unset($object->author); // Should be fk_user_author @@ -111,18 +112,18 @@ class DolibarrApi unset($object->timespent_withhour); unset($object->timespent_fk_user); unset($object->timespent_note); - + unset($object->statuts); unset($object->statuts_short); unset($object->statuts_logo); unset($object->statuts_long); - + unset($object->element); unset($object->fk_element); unset($object->table_element); unset($object->table_element_line); unset($object->picto); - + // Remove the $oldcopy property because it is not supported by the JSON // encoder. The following error is generated when trying to serialize // it: "Error encoding/decoding JSON: Type is not supported" @@ -152,7 +153,7 @@ class DolibarrApi } } }*/ - + return $object; } @@ -187,12 +188,12 @@ class DolibarrApi return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray,$resource_id,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); } - + /** * Return if a $sqlfilters parameter is valid - * + * * @param string $sqlfilters sqlfilter string - * @return boolean True if valid, False if not valid + * @return boolean True if valid, False if not valid */ function _checkFilters($sqlfilters) { @@ -216,22 +217,22 @@ class DolibarrApi } return true; } - + /** * Function to forge a SQL criteria - * + * * @param array $matches Array of found string by regex search * @return string Forged criteria. Example: "t.field like 'abc%'" */ static function _forge_criteria_callback($matches) { global $db; - + //dol_syslog("Convert matches ".$matches[1]); if (empty($matches[1])) return ''; $tmp=explode(':',$matches[1]); if (count($tmp) < 3) return ''; - + $tmpescaped=$tmp[2]; if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { @@ -242,5 +243,5 @@ class DolibarrApi $tmpescaped = $db->escape($tmpescaped); } return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; - } + } } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php new file mode 100644 index 00000000000..ca10b2befce --- /dev/null +++ b/htdocs/api/class/api_documents.class.php @@ -0,0 +1,143 @@ + + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016 Jean-François Ferry + * + * 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 . + */ + +use Luracast\Restler\RestException; +use Luracast\Restler\Format\UploadFormat; + + +require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; + +/** + * API class for receive files + * + * @access protected + * @class Documents {@requires user,external} + */ +class Documents extends DolibarrApi +{ + + /** + * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object + */ + static $DOCUMENT_FIELDS = array( + 'name', + 'modulepart', + 'file' + ); + + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } + + /** + * Return a document + * + * @param string $module_part Module part for file + * @param string $filename File name + * + * @return array + * @throws RestException + * + */ + public function get($module_part, $filename) { + + } + + + /** + * Receive file + * + * @param array $request_data Request datas + * + * @return bool State of copy + * @throws RestException + */ + public function post($request_data) { + global $conf; + + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + if (!DolibarrApiAccess::$user->rights->ecm->upload) { + throw new RestException(401); + } + + // Suppression de la chaine de caractere ../ dans $original_file + $original_file = str_replace("../","/", $request_data['name']); + $refname = str_replace("../","/", $request_data['refname']); + + // find the subdirectory name as the reference + if (empty($request_data['refname'])) $refname=basename(dirname($original_file)."/"); + + // Security: + // On interdit les remontees de repertoire ainsi que les pipe dans + // les noms de fichiers. + if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) + { + throw new RestException(401,'Refused to deliver file '.$original_file); + } + if (preg_match('/\.\./',$refname) || preg_match('/[<>|]/',$refname)) + { + throw new RestException(401,'Refused to deliver file '.$refname); + } + + $modulepart = $request_data['modulepart']; + + // Check mandatory fields + $result = $this->_validate_file($request_data); + + $upload_dir = DOL_DATA_ROOT . '/' .$modulepart.'/'.dol_sanitizeFileName($refname); + $destfile = $upload_dir . $original_file; + + if (!is_dir($upload_dir)) { + throw new RestException(401,'Directory not exists : '.$upload_dir); + } + + $file = $_FILES['file']; + $srcfile = $file['tmp_name']; + $res = dol_move($srcfile, $destfile, 0, 1); + + if (!$res) { + throw new RestException(500); + } + + return $res; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + function _validate_file($data) { + $result = array(); + foreach (Documents::$DOCUMENT_FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $result[$field] = $data[$field]; + } + return $result; + } +} diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 8ad60c4b340..5db8d7a78c9 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -56,16 +56,18 @@ if (empty($conf->global->MAIN_MODULE_API)) exit; } - $api = new DolibarrApi($db); // Enable the Restler API Explorer. // See https://github.com/Luracast/Restler-API-Explorer for more info. $api->r->addAPIClass('Luracast\\Restler\\Explorer'); -$api->r->setSupportedFormats('JsonFormat', 'XmlFormat'); +$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); $api->r->addAuthenticationClass('DolibarrApiAccess',''); +// Define accepted mime types +UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); + $listofapis = array(); $modulesdir = dolGetModulesDirs(); @@ -86,7 +88,7 @@ foreach ($modulesdir as $dir) $module = strtolower($reg[1]); $moduledirforclass = $module; $moduleforperm = $module; - + if ($module == 'propale') { $moduledirforclass = 'comm/propal'; $moduleforperm='propal'; @@ -119,7 +121,7 @@ foreach ($modulesdir as $dir) $moduledirforclass = 'fourn'; } //dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass); - + // Defined if module is enabled $enabled=true; if (empty($conf->$moduleforperm->enabled)) $enabled=false; @@ -142,7 +144,7 @@ foreach ($modulesdir as $dir) while (($file_searched = readdir($handle_part))!==false) { if ($file_searched == 'api_access.class.php') continue; - + // Support of the deprecated API. if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg)) { diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php new file mode 100644 index 00000000000..ea0c218027f --- /dev/null +++ b/test/phpunit/RestAPIDocumentTest.php @@ -0,0 +1,183 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/RestAPIDocumentTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php. + */ +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/geturl.lib.php'; + +if (empty($user->id)) { + echo "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; +$conf->global->MAIN_UMASK = '0666'; + +/** + * Class for PHPUnit tests. + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class RestAPIDocumentTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + protected $api_url; + protected $api_key; + + /** + * Constructor + * We save global variables into local variables. + * + * @return DateLibTest + */ + public function __construct() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf = $conf; + $this->savuser = $user; + $this->savlangs = $langs; + $this->savdb = $db; + + echo __METHOD__.' db->type='.$db->type.' user->id='.$user->id; + //print " - db ".$db->db; + echo "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + echo __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + echo __METHOD__."\n"; + } + + /** + * Init phpunit tests. + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; + + $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; + + $login = 'admin'; + $password = 'admin'; + $url = $this->api_url.'/login?login='.$login.'&password='.$password; + // Call the API login method to save api_key for this test class + $result = getURLContent($url, 'GET', '', 1, array()); + echo __METHOD__.' result = '.var_export($result, true)."\n"; + echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; + $this->assertEquals($result['curl_error_no'], ''); + $object = json_decode($result['content'], true); + $this->assertNotNull($object, 'Parsing of json result must no be null'); + $this->assertEquals('200', $object['success']['code']); + + $this->api_key = $object['success']['token']; + echo __METHOD__." api_key: $this->api_key \n"; + + echo __METHOD__."\n"; + } + + /** + * End phpunit tests. + */ + protected function tearDown() + { + echo __METHOD__."\n"; + } + + /** + * testRestReceiveDocument. + * + * @return int + */ + public function testRestReceiveDocument() + { + global $conf,$user,$langs,$db; + + $url = $this->api_url.'/documents/?api_key='.$this->api_key; + + $fileName = 'img250x20.png'; + $filePath = dirname(__FILE__).'/'.$fileName; + $mimetype = mime_content_type($filePath); + // Init Curl file object + // See https://wiki.php.net/rfc/curl-file-upload + $cfile = curl_file_create($filePath, $mimetype); + + echo __METHOD__.' Request POST url='.$url."\n"; + + // Send to existant directory + $data = array( + 'modulepart' => 'facture', + 'file' => $cfile, + 'refname' => 'AV1303-0003', + 'name' => $fileName, // Name for destination + 'type' => $mimetype, ); + + $result = getURLContent($url, 'POST', $data, 1); + + echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; + echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; + $this->assertEquals($result['curl_error_no'], ''); + $this->assertEquals($result['content'], 'true'); + + // Send to unexistant directory + $data = array( + 'modulepart' => 'facture', + 'file' => $cfile, + 'name' => 'AV1303-0003STSEIUDEISRESIJLEU/'.$fileName, // Name for destination + 'type' => $mimetype, ); + + $result2 = getURLContent($url, 'POST', $data, 1); + echo __METHOD__.' Result for sending document: '.var_export($result2, true)."\n"; + echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; + + $object = json_decode($result2['content'], true); + $this->assertNotNull($object, 'Parsing of json result must no be null'); + $this->assertEquals('401', $object['error']['code']); + } +} From cdfbed5d084215994320f82bd98315373e018034 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Dec 2016 17:36:22 +0100 Subject: [PATCH 003/505] 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 004/505] 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 005/505] 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 006/505] 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 007/505] 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 008/505] 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 009/505] 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 010/505] 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 011/505] 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 012/505] 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 013/505] 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 014/505] 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 015/505] 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 016/505] 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 017/505] 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 = ''."\n"; + print "\n"; + print ''."\n"; + print "\n"; + + return; +} + + +/** + * Show footer of company in HTML pages + * + * @param Societe $fromcompany Third party + * @param Translate $langs Output language + * @return void + */ +function html_print_stripe_footer($fromcompany,$langs) +{ + global $conf; + + // Juridical status + $line1=""; + if ($fromcompany->forme_juridique_code) + { + $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); + } + // Capital + if ($fromcompany->capital) + { + $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); + } + // Prof Id 1 + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + { + $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; + } + // Prof Id 2 + if ($fromcompany->idprof2) + { + $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; + } + + // Second line of company infos + $line2=""; + // Prof Id 3 + if ($fromcompany->idprof3) + { + $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; + } + // Prof Id 4 + if ($fromcompany->idprof4) + { + $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; + } + // IntraCommunautary VAT + if ($fromcompany->tva_intra != '') + { + $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; + } + + print '


    '."\n"; + print '
    '."\n"; + print $fromcompany->name.'
    '; + print $line1.'
    '; + print $line2; + print '
    '."\n"; +} + diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c8b18c81987..ef9a08524b3 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1361,7 +1361,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','websites'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ad4ec25df1d..144df2d12f8 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1371,7 +1371,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','websites'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) From de832d90a96693e35db3a618eedc183e93e0e754 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 00:50:53 +0100 Subject: [PATCH 024/505] Refactoring --- htdocs/core/class/coreobject.class.php | 522 ++++++++++++++++--------- 1 file changed, 336 insertions(+), 186 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 312120c59bf..5619361547e 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -25,10 +25,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -class CoreObject extends CommonObject { - - public $db; - +class CoreObject extends CommonObject +{ public $withChild = true; public $error = ''; @@ -41,217 +39,326 @@ class CoreObject extends CommonObject { * * @param DoliDB $db Database handler */ - function __construct(DoliDB &$db) { - - + function __construct(DoliDB &$db) + { + $this->db = $db; } - - protected function init() { - + + /** + * Function to init fields + * + * @return bool + */ + protected function init() + { $this->id = 0; $this->datec = 0; $this->tms = 0; - 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} = ''; - } + 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; + + $this->to_delete=false; + $this->is_clone=false; return true; } - else{ + else + { return false; } } - - private function checkFieldType($field, $type) { - - if( isset($this->__fields[$field]) && method_exists($this, 'is_'.$type)) { + + /** + * Test type of field + * + * @param string $field name of field + * @param string $type type of field to test + * @return value of field or false + */ + 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; - + else + { + return false; + } } - - private function is_date(Array &$info){ - + + /** + * 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; - } - - private function is_array($info) { - - if(is_array($info)) { + + /** + * 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; } - - - private function is_null($info){ - if(is_array($info)) { + + /** + * 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; } - - private function is_int($info){ - - if(is_array($info)) { + + /** + * 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; } - private function is_float($info){ - if(is_array($info)) { + + /** + * 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; + } + else return false; } - - private function is_text($info){ - if(is_array($info)) { + + /** + * 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; + } + else return false; } - private function is_index($info){ - if(is_array($info)) { + + /** + * 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; + } + else return false; } - - private function set_save_query(){ - + + + /** + * 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})){ + foreach ($this->__fields as $field=>$info) + { + if($this->is_date($info)) + { + if(empty($this->{$field})) + { $query[$field] = NULL; } - else{ + else + { $query[$field] = $this->db->idate($this->{$field}); } } - else if($this->is_array($info)){ - $query[$field] = serialize($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_int($info)) + { + $query[$field] = (int) price2num($this->{$field}); } - - else if($this->is_float($info)){ - $query[$field] = (double)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}); + elseif($this->is_null($info)) + { + $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field}); } - else{ + else + { $query[$field] = $this->{$field}; } - } return $query; } - - private function get_field_list(){ - + + + /** + * Function to concat keys of fields + * + * @return string + */ + private function get_field_list() + { $keys = array_keys($this->__fields); - return implode(',', $keys); } - - 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; + + /** + * 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)){ + 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})); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); } - elseif($this->is_int($info)){ + elseif($this->is_int($info)) + { $this->{$field} = (int)$obj->{$field}; } - elseif($this->is_float($info)){ + elseif($this->is_float($info)) + { $this->{$field} = (double)$obj->{$field}; } - elseif($this->is_null($info)){ + 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); + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); } - else{ + else + { $this->{$field} = $obj->{$field}; } } } - - public function fetch($id, $loadChild = true) { + + /** + * Get object and children from database + * + * @param int $id Id of object to load + * @param bool $loadChild used to load children from database + * @return int >0 if OK, <0 if KO, 0 if not found + */ + 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; - if(empty($id)) return false; + $res = $this->db->query($sql); + if($obj = $this->db->fetch_object($res)) + { + $this->id = $id; + $this->set_vars_by_db($obj); - $sql = 'SELECT '.$this->get_field_list().',datec,tms - FROM '.MAIN_DB_PREFIX.$this->table_element.' - 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); - $this->datec=$this->db->idate($obj->datec); - $this->tms=$this->db->idate($obj->tms); - - if($loadChild) $this->fetchChild(); + if ($loadChild) $this->fetchChild(); - return $this->id; + return $this->id; } - else { - $this->error = $this->db->lasterror(); - - return false; + else + { + $this->error = $this->db->lasterror(); + return false; } - } - public function addChild($tabName, $id='', $key='id', $try_to_load = false) { - if(!empty($id)) { - foreach($this->{$tabName} as $k=>&$object) { + + + /** + * Function to instantiate a new child + * + * @param string $tabName Table name of child + * @param int $id If id is given, we try to return his key if exist or load if we try_to_load + * @param string $key Attribute name of the object id + * @param bool $try_to_load Force the fetch if an id is given + * @return int + */ + public function addChild($tabName, $id=0, $key='id', $try_to_load = false) + { + if(!empty($id)) + { + foreach($this->{$tabName} as $k=>&$object) + { if($object->{$key} === $id) return $k; - } } @@ -259,28 +366,39 @@ class CoreObject extends CommonObject { $className = ucfirst($tabName); $this->{$tabName}[$k] = new $className($this->db); - if($id>0 && $key==='id' && $try_to_load) { + if($id>0 && $key==='id' && $try_to_load) + { $this->{$tabName}[$k]->fetch($id); } - - + return $k; } - - public function removeChild($tabName, $id, $key='id') { - foreach($this->{$tabName} as &$object) { - - if($object->{$key} == $id) { + + + /** + * Function to set a child as to delete + * + * @param string $tabName Table name of child + * @param int $id Id of child to set as to delete + * @param string $key Attribute name of the object id + * @return bool + */ + 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() { + + + public function fetchChild() + { if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { foreach($this->childtables as &$childTable) { @@ -390,76 +508,108 @@ class CoreObject extends CommonObject { } } - public function delete(User &$user){ - if($this->id>0){ - $this->call_trigger(strtoupper($this->element). '_DELETE', $user); - - $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); - if(!empty($this->{$className})) { - foreach($this->{$className} as &$object) { - - $object->delete($user); - - } - } - - } - } - - - + public function delete(User &$user) + { + if($this->id>0) + { + $error = 0; + + $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); + if ($result < 0) $error++; + + + if (!$error) + { + $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); + if (!empty($this->{$className})) + { + foreach($this->{$className} as &$object) + { + $object->delete($user); + } + } + } + } + } + } - - - } - public function get_date($field,$format='') { + + + /** + * Function to get a formatted date + * + * @param string $field Attribute to return + * @param string $format Output date format + * @return string + */ + public function get_date($field, $format='') + { if(empty($this->{$field})) return ''; - else { + else + { return dol_print_date($this->{$field}, $format); } - } - - public function set_date($field,$date){ - if(empty($date)) { + /** + * Function to set date in field + * + * @param string $field field to set + * @param string $date formatted date to convert + * @return mixed + */ + public function set_date($field, $date) + { + if (empty($date)) + { $this->{$field} = 0; } - else { + 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')) { + + + /** + * Function to update current object + * + * @param array $Tab Array of values + */ + 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')){ + 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, 'float') ) + { + $this->{$key} = (double) price2num($value); } - else if( $this->checkFieldType($key,'int') ) { - $this->{$key} = (int)price2num($value); + else if( $this->checkFieldType($key, 'int') ) { + $this->{$key} = (int) price2num($value); } - else { + else + { $this->{$key} = @stripslashes($value); } - } } From 269645dfc77143daca1b1f46771460bf3627f6e3 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 10:48:06 +0100 Subject: [PATCH 025/505] Add method documentations --- htdocs/core/class/coreobject.class.php | 280 +++++++++++++++---------- 1 file changed, 172 insertions(+), 108 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 5619361547e..92597b40ffd 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -28,13 +28,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class CoreObject extends CommonObject { public $withChild = true; - + + /** + * @var string Error string + */ public $error = ''; - /* + + /** + * @var string[] Array of error strings + */ + public $errors=array(); + + /** * @var Array $_fields Fields to synchronize with Database */ protected $__fields=array(); - /** + + /** * Constructor * * @param DoliDB $db Database handler @@ -338,6 +348,7 @@ class CoreObject extends CommonObject else { $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; return false; } } @@ -397,148 +408,202 @@ class CoreObject extends CommonObject } - public function fetchChild() + /** + * Function to fetch children objects + */ + public function fetchChild() { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { + $className = ucfirst($childTable); - 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->id; - $res = $this->db->query($sql); - - if($res) { - $Tab=array(); - while($obj = $this->db->fetch_object($res)) { - - $o=new $className($this->db); - $o->fetch($obj->rowid); - - $this->{$className}[] = $o; - - } - - } + $this->{$className}=array(); + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; + $res = $this->db->query($sql); + + if($res) + { + while($obj = $this->db->fetch_object($res)) + { + $o=new $className($this->db); + $o->fetch($obj->rowid); + + $this->{$className}[] = $o; + } + } + else + { + $this->errors[] = $this->db->lasterror(); + } } - } - } - - public function saveChild(User &$user) { - - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) { - foreach($this->childtables as &$childTable) { - + + /** + * Function to update children data + * + * @param User $user user object + */ + public function saveChild(User &$user) + { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { $className = ucfirst($childTable); - if(!empty($this->{$className})) { - foreach($this->{$className} as $i => &$object) { - + 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); // 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($user); - } - else { - - $query = array(); - - $query = $this->set_save_query(); - $query['rowid']=$this->id; - - $res = $this->db->update($this->table_element,$query,array('rowid')); - - if($res) { - - $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); - - $this->saveChild($user); - - return true; - } - else{ - $this->error = $this->db->lasterror(); - - return false; - } - - } - return $this->id; - - + + + /** + * Function to update object or create or delete if needed + * + * @param User $user user object + * @return < 0 if ko, > 0 if ok + */ + public function update(User &$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 + elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); + + $error = 0; + $this->db->begin(); + + $query = $this->set_save_query(); + $query['rowid'] = $this->id; + + $res = $this->db->update($this->table_element, $query, array('rowid')); + if ($res) + { + $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); + if ($result < 0) $error++; + else $this->saveChild($user); + } + else + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } + + if (empty($error)) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } + } - public function create(User &$user) { - if($this->id>0) return $this->update($user); - - $query = array(); + + /** + * Function to create object in database + * + * @param User $user user object + * @return < 0 if ko, > 0 if ok + */ + public function create(User &$user) + { + if($this->id > 0) return $this->update($user); + + $error = 0; + $this->db->begin(); + $query = $this->set_save_query(); - $query['datec'] = date("Y-m-d H:i:s",$this->datec); + $query['datec'] = date("Y-m-d H:i:s", $this->datec); - $res = $this->db->insert($this->table_element,$query); - - if($res) { + $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; + if ($result < 0) $error++; + else $this->saveChild($user); } - else{ - - $this->error = $this->db->lasterror(); - - return false; + else + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; } - + + if (empty($error)) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } } + + /** + * Function to delete object in database + * + * @param User $user user object + * @return < 0 if ko, > 0 if ok + */ public function delete(User &$user) { - if($this->id>0) - { - $error = 0; + if ($this->id <= 0) return 0; - $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); - if ($result < 0) $error++; + $error = 0; + $this->db->begin(); + $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); + if ($result < 0) $error++; - if (!$error) + if (!$error) + { + $this->db->delete($this->table_element, array('rowid' => $this->id), array('rowid')); + if($this->withChild && !empty($this->childtables)) { - $this->db->delete($this->table_element, array('rowid'=>$this->id), array('rowid')); - - if($this->withChild && !empty($this->childtables)) + foreach($this->childtables as &$childTable) { - foreach($this->childtables as &$childTable) + $className = ucfirst($childTable); + if (!empty($this->{$className})) { - $className = ucfirst($childTable); - if (!empty($this->{$className})) + foreach($this->{$className} as &$object) { - foreach($this->{$className} as &$object) - { - $object->delete($user); - } + $object->delete($user); } } } } + } - } + if (empty($error)) + { + $this->db->commit(); + return 1; + } + else + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $this->db->rollback(); + return -1; + } } @@ -554,7 +619,6 @@ class CoreObject extends CommonObject if(empty($this->{$field})) return ''; else { - return dol_print_date($this->{$field}, $format); } } From ae33e40dc872f1d37f99df04e0d1cd2413a413ea Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 17:32:42 +0100 Subject: [PATCH 026/505] Refactoring and add method comments --- htdocs/core/class/coreobject.class.php | 15 +- htdocs/inventory/class/inventory.class.php | 567 +++++++++++++-------- 2 files changed, 370 insertions(+), 212 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 92597b40ffd..ec6442c2302 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -29,16 +29,6 @@ class CoreObject extends CommonObject { public $withChild = true; - /** - * @var string Error string - */ - public $error = ''; - - /** - * @var string[] Array of error strings - */ - public $errors=array(); - /** * @var Array $_fields Fields to synchronize with Database */ @@ -349,7 +339,7 @@ class CoreObject extends CommonObject { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; - return false; + return -1; } } @@ -650,6 +640,7 @@ class CoreObject extends CommonObject * Function to update current object * * @param array $Tab Array of values + * @return int */ public function set_values(&$Tab) { @@ -675,6 +666,8 @@ class CoreObject extends CommonObject $this->{$key} = @stripslashes($value); } } + + return 1; } } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 344252f4dc4..05996d02489 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -26,7 +26,6 @@ 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'; @@ -60,7 +59,11 @@ class Inventory extends CoreObject * @var string */ public $title; - + + /** + * Attribute object linked with database + * @var array + */ protected $__fields=array( 'fk_warehouse'=>array('type'=>'integer','index'=>true) ,'entity'=>array('type'=>'integer','index'=>true) @@ -68,58 +71,70 @@ class Inventory extends CoreObject ,'date_inventory'=>array('type'=>'date') ,'title'=>array('type'=>'string') ); - - public $db; - + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ public function __construct(DoliDB &$db) { global $conf; - - $this->db = &$db; - + + parent::__construct($db); parent::init(); $this->status = 0; $this->entity = $conf->entity; $this->errors = array(); $this->amount = 0; - } - + + /** + * Function to sort children object + */ public function sort_det() { - if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort')); } - - public function fetch($id,$annexe = true) + + /** + * Get object and children from database + * + * @param int $id Id of object to load + * @param bool $loadChild used to load children from database + * @return int >0 if OK, <0 if KO, 0 if not found + */ + public function fetch($id, $loadChild = true) { - - if(!$annexe) $this->withChild = false; + if(!$loadChild) $this->withChild = false; - $res = parent::fetch($id); - - if($res>0) { + $res = parent::fetch($id, $loadChild); + 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; + if(!empty($this->Inventorydet )) + { + foreach($this->Inventorydet as &$det) + { + $this->amount += $det->qty_view * $det->pmp; } - } } return $res; } - - + + /** + * Custom function call by usort + * + * @param Inventorydet $objA first Inventorydet object + * @param Inventorydet $objB second Inventorydet object + * @return int + */ private function customSort(&$objA, &$objB) { - global $db; - $r = strcmp(strtoupper(trim($objA->product->ref)), strtoupper(trim($objB->product->ref))); if ($r < 0) $r = -1; @@ -128,42 +143,109 @@ class Inventory extends CoreObject return $r; } - - public function changePMP(User &$user) { - if(!empty($this->Inventorydet)) { + + /** + * @param User $user user object + * @return int + */ + public function changePMP(User &$user) + { + $error = 0; + $this->db->begin(); + + if(!empty($this->Inventorydet)) + { foreach ($this->Inventorydet as $k => &$Inventorydet) { - - if($Inventorydet->new_pmp>0) { + 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 ); - + $res = $this->db->query('UPDATE '.MAIN_DB_PREFIX.'product as p SET pmp = '.$Inventorydet->pmp.' WHERE rowid = '.$Inventorydet->fk_product ); + if (!$res) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + } } } } - return parent::update($user); - + $res = parent::update($user); + if (!$res) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + } + + + if (!$error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } - + + /** + * Function to update object or create or delete if needed + * + * @param User $user user object + * @return < 0 if ko, > 0 if ok + */ public function update(User &$user) { - - //si on valide l'inventaire on sauvegarde le stock à cette instant + $error = 0; + $this->db->begin(); + + // if we valid the inventory we save the stock at the same time if ($this->status) { - $this->regulate(); + $res = $this->regulate(); + if ($res < 0) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + } } - - parent::update($user); + + $res = parent::update($user); + if (!$res) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + } + + if (!$error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } } - + + /** + * Function to update current object + * + * @param array $Tab Array of values + * @return int + */ public function set_values(&$Tab) { - global $db,$langs; + global $langs; if (isset($Tab['qty_to_add'])) { @@ -174,10 +256,10 @@ class Inventory extends CoreObject if ($qty < 0) { $this->errors[] = $langs->trans('inventoryErrorQtyAdd'); - return 0; + return -1; } - $product = new Product($db); + $product = new Product($this->db); $product->fetch($this->Inventorydet[$k]->fk_product); $this->Inventorydet[$k]->pmp = $product->pmp; @@ -185,47 +267,73 @@ class Inventory extends CoreObject } } - parent::set_values($Tab); + return parent::set_values($Tab); } - - public function deleteAllLine(User &$user) { - - foreach($this->Inventorydet as &$det) { + + /** + * Function to delete all Inventorydet + * + * @param User $user user object + * @return < 0 if ko, > 0 if ok + */ + public function deleteAllLine(User &$user) + { + foreach($this->Inventorydet as &$det) + { $det->to_delete = true; } - $this->update($user); - - $this->Inventorydet=array(); - + $res = $this->update($user); + + if ($res > 0) $this->Inventorydet = array(); + else return -1; } - - public function add_product($fk_product, $fk_entrepot='') { - + + /** + * Function to add Inventorydet + * + * @param int $fk_product fk_product of Inventorydet + * @param int $fk_warehouse fk_warehouse target + * @return bool + */ + public function add_product($fk_product, $fk_warehouse=0) + { $k = $this->addChild('Inventorydet'); $det = &$this->Inventorydet[$k]; $det->fk_inventory = $this->id; $det->fk_product = $fk_product; - $det->fk_warehouse = empty($fk_entrepot) ? $this->fk_warehouse : $fk_entrepot; + $det->fk_warehouse = empty($fk_warehouse) ? $this->fk_warehouse : $fk_warehouse; $det->load_product(); $date = $this->get_date('date_inventory', 'Y-m-d'); - if(empty($date))$date = $this->get_date('datec', 'Y-m-d'); - $det->setStockDate( $date , $fk_entrepot); + if(empty($date)) $date = $this->get_date('datec', 'Y-m-d'); + $det->setStockDate( $date , $fk_warehouse); return true; } - + + /** + * Duplication method product to add datem + * Adjust stock in a warehouse for product + * + * @param int $fk_product id of product + * @param int $fk_warehouse id of warehouse + * @param double $nbpiece nb of units + * @param int $movement 0 = add, 1 = remove + * @param string $label Label of stock movement + * @param double $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. + * @param string $inventorycode Inventory code + * @return int <0 if KO, >0 if OK + */ public function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') { - global $conf, $db, $langs, $user; - - /* duplication method product to add datem */ + global $conf, $user; + if ($fk_warehouse) { - $db->begin(); + $this->db->begin(); require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; @@ -234,7 +342,7 @@ class Inventory extends CoreObject $datem = empty($conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT) ? dol_now() : $this->date_inventory; - $movementstock=new MouvementStock($db); + $movementstock=new MouvementStock($this->db); $movementstock->origin = new stdClass(); $movementstock->origin->element = 'inventory'; $movementstock->origin->id = $this->id; @@ -242,7 +350,7 @@ class Inventory extends CoreObject if ($result >= 0) { - $db->commit(); + $this->db->commit(); return 1; } else @@ -250,19 +358,25 @@ class Inventory extends CoreObject $this->error=$movementstock->error; $this->errors=$movementstock->errors; - $db->rollback(); + $this->db->rollback(); return -1; } } } - + + /** + * Function to regulate stock + * + * @return int + */ public function regulate() { - global $db,$user,$langs,$conf; + global $langs,$conf; - if($conf->global->INVENTORY_DISABLE_VIRTUAL){ + if($conf->global->INVENTORY_DISABLE_VIRTUAL) + { $pdt_virtuel = false; - // Test si pdt virtuel est activé + // Test if virtual product is enabled if($conf->global->PRODUIT_SOUSPRODUITS) { $pdt_virtuel = true; @@ -272,106 +386,138 @@ class Inventory extends CoreObject foreach ($this->Inventorydet as $k => $Inventorydet) { - $product = new Product($db); + $product = new Product($this->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->id.'&action=view', 1); + //$href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1); - $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock')); + $res = $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock')); + if ($res < 0) return -1; } } - if($conf->global->INVENTORY_DISABLE_VIRTUAL){ - // Test si pdt virtuel était activé avant la régule + if($conf->global->INVENTORY_DISABLE_VIRTUAL) + { + // Test if virtual product was enabled before regulate if($pdt_virtuel) $conf->global->PRODUIT_SOUSPRODUITS = 1; } return 1; } - - public function getTitle() { + + /** + * Get the title + * @return string + */ + public function getTitle() + { global $langs; 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().''; - - } - - 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); + + + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @return string + */ + public function getNomUrl($withpicto = 1) + { + return ''.($withpicto ? img_picto('','object_list.png','',0).' ' : '').$this->getTitle().''; + } + + /** + * Function to add products by default from warehouse and children + * + * @param $fk_warehouse + * @param int $fk_category + * @param int $fk_supplier + * @param int $only_prods_in_stock + * + * @return int + */ + public function add_products_for($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0) + { + $warehouse = new Entrepot($this->db); + $warehouse->fetch($fk_warehouse); $TChildWarehouses = array($fk_warehouse); - $e->get_children_warehouses($fk_warehouse, $TChildWarehouses); + $warehouse->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).')'; + $sql = 'SELECT ps.fk_product, ps.fk_entrepot'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product_stock ps'; + $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid)'; + $sql.= ' 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'; + 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'; + $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)){ + if($res) + { + while($obj = $this->db->fetch_object($res)) + { $this->add_product($obj->fk_product, $obj->fk_entrepot); } + + return 1; } - - + else + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + return -1; + } } - - static function getLink($id) { + + /** + * Return clicable link of inventory object + * + * @param int $id id of inventory + * @param int $withpicto Add picto into link + * @return string + */ + static function getLink($id, $withpicto=1) + { global $langs,$db; - $i = new Inventory($db); - if($i->fetch($id, false)>0) return $i->getNomUrl(); + $inventory = new Inventory($db); + if($inventory->fetch($id, false) > 0) return $inventory->getNomUrl($withpicto); else return $langs->trans('InventoryUnableToFetchObject'); - } - - static function getSQL($type) { + + /** + * Function to get the sql select of inventory + * @param string $type + * @return string + */ + static function getSQL($type) + { global $conf; - - if($type=='All') { - - $sql="SELECT i.rowid,i.title, 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; - + + $sql = ''; + if($type == 'All') + { + $sql = 'SELECT i.rowid,i.title, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'inventory i'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot e ON (e.rowid = i.fk_warehouse)'; + $sql.= ' WHERE i.entity = '.(int) $conf->entity; } return $sql; } - } class Inventorydet extends CoreObject @@ -404,138 +550,157 @@ class Inventorydet extends CoreObject ,'pa'=>array('type'=>'float') ,'new_pmp'=>array('type'=>'float') ); - - - function __construct(&$db) + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct(DoliDB &$db) { global $conf; - - $this->db = &$db; - + + parent::__construct($db); parent::init(); $this->entity = $conf->entity; $this->errors = array(); $this->product = null; - $this->current_pa = 0; - } - + + /** + * Get object and children from database + * + * @param int $id id of inventorydet object + * @return int + */ function fetch($id) { - global $conf; - $res = parent::fetch($id); $this->load_product(); $this->fetch_current_pa(); return $res; } - - function fetch_current_pa() { + + /** + * Function to get the unit buy price + * + * @return bool + */ + 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){ + if($this->pa > 0) + { $this->current_pa = $this->pa; } - else { - + 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($date, $fk_warehouse) { - - list($pmp,$stock) = $this->getPmpStockFromDate($date, $fk_warehouse); - + + /** + * Function to set pa attribute from date en fk_warehouse + * + * @param date $date date value + * @param int $fk_warehouse fk_warehouse target + */ + function setStockDate($date, $fk_warehouse) + { + list($pmp, $stock) = $this->getPmpStockFromDate($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"; - + $sql = 'SELECT price FROM '.MAIN_DB_PREFIX.'stock_mouvement'; + $sql.= ' WHERE fk_entrepot = '.$fk_warehouse; + $sql.= ' AND fk_product = '.$this->fk_product; + $sql.= ' AND (origintype=\'order_supplier\' || origintype=\'invoice_supplier\')'; + $sql.= ' AND price > 0'; + $sql.= ' AND datem <= \''.$date.' 23:59:59\''; + $sql.= ' ORDER BY datem DESC LIMIT 1'; + $res = $this->db->query($sql); - - if($res && $obj = $this->db->fetch_object($res)) { + if($res && $obj = $this->db->fetch_object($res)) + { $last_pa = $obj->price; } - + $this->pa = $last_pa; - } - function getPmpStockFromDate( $date, $fk_warehouse){ - + + /** + * Get the last pmp and last stock from date and warehouse + * + * @param date $date date to check + * @param int $fk_warehouse id of warehouse + * @return array + */ + function getPmpStockFromDate($date, $fk_warehouse) + { $res = $this->product->load_stock(); - if($res>0) { + 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; - } - + $pmp = $this->product->pmp; } //All Stock mouvement between now and inventory date - $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"; + $sql = 'SELECT value, price'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'stock_mouvement'; + $sql.= ' WHERE fk_product = '.$this->product->id; + $sql.= ' AND fk_entrepot = '.$fk_warehouse; + $sql.= ' AND datem > \''.date('Y-m-d 23:59:59', strtotime($date)).'\''; + $sql.= ' ORDER BY datem DESC'; - $res = $this->db->query($sql); $laststock = $stock; $lastpmp = $pmp; - if($res) { - while($mouvement = $this->db->fetch_object($res)) { - $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; - $laststock -= $mouvement->value; - $last_stock_value = $stock_value - ($mouvement->value * $price); - $lastpmp = ($laststock != 0) ? $last_stock_value / $laststock : $lastpmp; } - } - return array($lastpmp,$laststock); + return array($lastpmp, $laststock); } - + + /** + * Fetch the product linked with the line + * @return void + */ function load_product() { global $db; - if($this->fk_product>0) { + if($this->fk_product>0) + { $this->product = new Product($db); $this->product->fetch($this->fk_product); } - } - } From e3afa06cf310878b586c12fb7f771b9a9da5bf54 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 18:01:43 +0100 Subject: [PATCH 027/505] Fix inventory sql --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 12 ++++++------ htdocs/install/mysql/tables/llx_inventory.key.sql | 2 +- htdocs/install/mysql/tables/llx_inventory.sql | 4 ++-- htdocs/install/mysql/tables/llx_inventorydet.key.sql | 2 +- htdocs/install/mysql/tables/llx_inventorydet.sql | 4 ++-- 5 files changed, 12 insertions(+), 12 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 365d367b3f7..986faf2a74c 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 @@ -129,20 +129,20 @@ ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL; CREATE TABLE llx_inventory ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec DATETIME DEFAULT NULL, +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 DATETIME DEFAULT NULL +date_inventory datetime DEFAULT NULL ) ENGINE=InnoDB; CREATE TABLE llx_inventorydet ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec DATETIME DEFAULT NULL, +datec datetime DEFAULT NULL, tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, @@ -153,12 +153,12 @@ qty_stock double DEFAULT 0, qty_regulated double DEFAULT 0, pmp double DEFAULT 0, pa double DEFAULT 0, -new_pmp double DEFAULT 0, +new_pmp double DEFAULT 0 ) ENGINE=InnoDB; ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms); -ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (date_cre); +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 (date_cre); +ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); diff --git a/htdocs/install/mysql/tables/llx_inventory.key.sql b/htdocs/install/mysql/tables/llx_inventory.key.sql index 6596e88d817..bf76381e108 100644 --- a/htdocs/install/mysql/tables/llx_inventory.key.sql +++ b/htdocs/install/mysql/tables/llx_inventory.key.sql @@ -18,4 +18,4 @@ -- =================================================================== ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms); -ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (date_cre); +ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (datec); diff --git a/htdocs/install/mysql/tables/llx_inventory.sql b/htdocs/install/mysql/tables/llx_inventory.sql index dc4b66f1be2..f906699f5dd 100644 --- a/htdocs/install/mysql/tables/llx_inventory.sql +++ b/htdocs/install/mysql/tables/llx_inventory.sql @@ -20,12 +20,12 @@ CREATE TABLE llx_inventory ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec DATETIME DEFAULT NULL, +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 DATETIME DEFAULT NULL +date_inventory datetime DEFAULT NULL ) ENGINE=InnoDB; diff --git a/htdocs/install/mysql/tables/llx_inventorydet.key.sql b/htdocs/install/mysql/tables/llx_inventorydet.key.sql index 31c5884f60b..3cef44ba52a 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet.key.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet.key.sql @@ -18,5 +18,5 @@ -- =================================================================== ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms); -ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (date_cre); +ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); diff --git a/htdocs/install/mysql/tables/llx_inventorydet.sql b/htdocs/install/mysql/tables/llx_inventorydet.sql index c67ccd32a3f..20e48b877b5 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet.sql @@ -20,7 +20,7 @@ CREATE TABLE llx_inventorydet ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec DATETIME DEFAULT NULL, +datec datetime DEFAULT NULL, tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, @@ -31,6 +31,6 @@ qty_stock double DEFAULT 0, qty_regulated double DEFAULT 0, pmp double DEFAULT 0, pa double DEFAULT 0, -new_pmp double DEFAULT 0, +new_pmp double DEFAULT 0 ) ENGINE=InnoDB; From fce8e08b51a7d6a0160c925778e0e4458cd45330 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 18:13:39 +0100 Subject: [PATCH 028/505] Refactoring and fix --- htdocs/core/class/coreobject.class.php | 2 +- htdocs/core/class/listview.class.php | 31 +++--- htdocs/inventory/ajax/ajax.inventory.php | 18 ++-- htdocs/inventory/class/inventory.class.php | 5 +- htdocs/inventory/inventory.php | 6 +- htdocs/inventory/list.php | 108 ++++++++++----------- 6 files changed, 83 insertions(+), 87 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index ec6442c2302..6454c6e814b 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -517,7 +517,7 @@ class CoreObject extends CommonObject $this->db->begin(); $query = $this->set_save_query(); - $query['datec'] = date("Y-m-d H:i:s", $this->datec); + $query['datec'] = date("Y-m-d H:i:s", dol_now()); $res = $this->db->insert($this->table_element, $query); if($res) diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 46a766a1206..c0579a47850 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -19,21 +19,19 @@ along with this program. If not, see . */ -class Listview { +class Listview +{ - function __construct(&$db, $id ) { - + function __construct(&$db, $id) + { $this->db = &$db; - $this->id = $id; - $this->TTotalTmp=array(); - $this->sql = ''; - } - private function init(&$TParam) { - + + private function init(&$TParam) + { global $conf, $langs; if(!isset($TParam['hide']))$TParam['hide']=array(); @@ -574,7 +572,7 @@ class Listview { $this->init($TParam); - $this->parse_array($THeader, $TField, $TParam,$TField); + $this->parse_array($THeader, $TField, $TParam); list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam); $this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam); @@ -610,13 +608,14 @@ class Listview { return $sql; } - private function parse_array(&$THeader, &$TField, &$TParam, $TField) { - $first=true; - - $this->THideFlip = array_flip($TParam['hide']); + private function parse_array(&$THeader, &$TField, &$TParam) + { + $first = true; + + $this->THideFlip = array_flip($TParam['hide']); $this->TTotalTmp=array(); - if(empty($TField)) return false; + if (empty($TField)) return false; foreach($TField as $row) { if($first) { @@ -844,7 +843,7 @@ class Listview { $this->TTotalTmp=array(); $this->THideFlip = array_flip($TParam['hide']); -var_dump($this->sql); + $res = $this->db->query($this->sql); if($res!==false) { diff --git a/htdocs/inventory/ajax/ajax.inventory.php b/htdocs/inventory/ajax/ajax.inventory.php index f2f5ef54903..c1f372806c8 100644 --- a/htdocs/inventory/ajax/ajax.inventory.php +++ b/htdocs/inventory/ajax/ajax.inventory.php @@ -6,20 +6,23 @@ $get = GETPOST('get'); $put = GETPOST('put'); - switch ($put) { + switch ($put) + { case 'qty': - if (!$user->rights->inventory->write) { echo -1; exit; } + if (empty($user->rights->inventory->write)) { echo -1; exit; } $fk_det_inventory = GETPOST('fk_det_inventory'); $det = new Inventorydet($db); - if( $det->fetch( $fk_det_inventory)) { + if( $det->fetch( $fk_det_inventory)) + { $det->qty_view+=GETPOST('qty'); $det->update($user); echo $det->qty_view; } - else { + else + { echo -2; } @@ -31,17 +34,18 @@ $fk_det_inventory = GETPOST('fk_det_inventory'); $det = new Inventorydet($db); - if( $det->fetch( $fk_det_inventory)) { + if( $det->fetch( $fk_det_inventory)) + { $det->new_pmp=price2num(GETPOST('pmp')); $det->update($user); echo $det->new_pmp; } - else { + else + { echo -2; } break; - } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 05996d02489..46f27906cc9 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -573,10 +573,11 @@ class Inventorydet extends CoreObject /** * Get object and children from database * - * @param int $id id of inventorydet object + * @param int $id id of inventorydet object + * @param bool $loadChild load children * @return int */ - function fetch($id) + function fetch($id, $loadChild = true) { $res = parent::fetch($id); $this->load_product(); diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index 7e43c3ce44e..403b148ec2c 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->load("stock"); $langs->load("inventory"); -if(!$user->rights->inventory->read) accessforbidden(); +if(empty($user->rights->inventory->read)) accessforbidden(); _action(); @@ -54,7 +54,7 @@ function _action() switch($action) { case 'create': - if (!$user->rights->inventory->create) accessforbidden(); + if (empty($user->rights->inventory->create)) accessforbidden(); $inventory = new Inventory($db); @@ -63,7 +63,7 @@ function _action() break; case 'confirmCreate': - if (!$user->rights->inventory->create) accessforbidden(); + if (empty($user->rights->inventory->create)) accessforbidden(); $inventory = new Inventory($db); $inventory->set_values($_POST); diff --git a/htdocs/inventory/list.php b/htdocs/inventory/list.php index c6846cfc618..2fb1a2b7f31 100644 --- a/htdocs/inventory/list.php +++ b/htdocs/inventory/list.php @@ -36,67 +36,59 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->load("stock"); $langs->load("inventory"); -if(!$user->rights->inventory->read) accessforbidden(); - -_list(); - - -function _list() -{ - - global $db, $conf, $langs, $user; +if (empty($user->rights->inventory->read)) accessforbidden(); - llxHeader('',$langs->trans('inventoryListTitle'),'',''); - - echo '
    '; - - $inventory = new Inventory($db); - $l = new ListView($db,'listInventory'); +llxHeader('',$langs->trans('inventoryListTitle'),'',''); - $THide = array('label','title'); +echo ''; - echo $l->render(Inventory::getSQL('All'), array( - 'link'=>array( - 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' - ) - ,'translate'=>array() - ,'hide'=>$THide - ,'type'=>array( - 'datec'=>'date' - ,'tms'=>'datetime' - ,'date_inventory'=>'date' - ) - ,'list'=>array( - 'title'=>$langs->trans('inventoryListTitle') - ,'messageNothing'=>$langs->trans('inventoryListEmpty') - ) - ,'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@)' - ) - ,'search'=>array( - 'date_inventory'=>'calendars' - ,'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")) - ) - )); +$inventory = new Inventory($db); +$list = new ListView($db,'listInventory'); + +$THide = array('label','title'); + +echo $list->render(Inventory::getSQL('All'), array( + 'link'=>array( + 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' + ) + ,'translate'=>array() + ,'hide'=>$THide + ,'type'=>array( + 'datec'=>'date' + ,'tms'=>'datetime' + ,'date_inventory'=>'date' + ) + ,'list'=>array( + 'title'=>$langs->trans('inventoryListTitle') + ,'messageNothing'=>$langs->trans('inventoryListEmpty') + ) + ,'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@)' + ) + ,'search'=>array( + 'date_inventory'=>'calendars' + ,'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")) + ) +)); - if ($user->rights->inventory->create) - { - print '
    '; - print ''.$langs->trans('inventoryCreate').''; - print '
    '; - } +if (!empty($user->rights->inventory->create)) +{ + print '
    '; + print ''.$langs->trans('inventoryCreate').''; + print '
    '; +} - echo '
    '; - - llxFooter(''); -} \ No newline at end of file +echo ''; + +llxFooter(''); +$db->close(); \ No newline at end of file From cb576e6c9932b814ebfe0ad5b686d35d287c1c33 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 18:26:10 +0100 Subject: [PATCH 029/505] Refactoring class --- htdocs/core/class/listview.class.php | 117 +++++++++++++++++++-------- htdocs/inventory/list.php | 2 +- 2 files changed, 83 insertions(+), 36 deletions(-) diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index c0579a47850..11a948472e4 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -21,7 +21,12 @@ class Listview { - + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $id html id + */ function __construct(&$db, $id) { $this->db = &$db; @@ -30,6 +35,12 @@ class Listview $this->sql = ''; } + /** + * Function to init fields + * + * @param array $TParam array of configuration of list + * @return bool + */ private function init(&$TParam) { global $conf, $langs; @@ -51,87 +62,123 @@ class Listview ,'orderUp'=>'' ,'id'=>$this->id ,'head_search'=>'' - ,'export'=>array() //TODO include native export - ,'view_type'=>'' //TODO to include graph or kanban instead of list + ,'export'=>array() + ,'view_type'=>'' ),$TParam['list']); $POSTList = GETPOST('Listview'); - if(empty($TParam['limit']))$TParam['limit']=array(); - if(!empty($POSTList[$this->id]['page'])) $TParam['limit']['page'] = $POSTList[$this->id]['page']; + if (empty($TParam['limit']))$TParam['limit'] = array(); + 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']); + $TParam['limit'] = array_merge(array('page'=>1, 'nbLine'=>$conf->liste_limit, 'global'=>0), $TParam['limit']); - if(!empty($POSTList[$this->id]['orderBy'])) { + if(!empty($POSTList[$this->id]['orderBy'])) + { $TParam['orderBy'] = $POSTList[$this->id]['orderBy']; } - } - private function getSearchNull($key, &$TParam) { + + + /** + * Function to know if we can search on null value + * @param string $key field name + * @param array $TParam array of configuration + * @return bool + */ + 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'])) { + } + + /** + * @param $key + * @param $TParam + * @return array + */ + 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) { + foreach ($TParam['search'][$key]['table'] as $prefix_table) + { $TPrefixe[] = $prefix_table.'.'; } } $TKey=array(); - if(!empty($TParam['search'][$key]['field'])) { + 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) { + foreach ($TParam['search'][$key]['field'] as $i => $field) + { $prefixe = !empty($TPrefixe[$i]) ? $TPrefixe[$i] : $TPrefixe[0]; $TKey[] = $prefixe. $field ; } - } else { - $TKey[] =$TPrefixe[0].$key; + } + else + { + $TKey[] = $TPrefixe[0].$key; } return $TKey; - } - - private function dateToSQLDate($date) { - + } + + /** + * @param $date + * @return int|string Date TMS or '' + */ + private function dateToSQLDate($date) + { return $this->db->jdate($date); } - - private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey) + + + /** + * @param $TSQLMore + * @param $value + * @param $sKey + */ + private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey) { if(is_array($value)) { - $TSQLDate=array(); if(!empty($value['start'])) { $valueDeb = $this->dateToSQLDate($value['start']); $TSQLDate[]=$sKey." >= '".$valueDeb." 00:00:00'" ; - } - + if(!empty($value['end'])) { $valueFin = $this->dateToSQLDate($value['end']); - $TSQLDate[]=$sKey." <= '".$valueFin." 23:59:59'" ; - + $TSQLDate[]=$sKey." <= '".$valueFin." 23:59:59'" ; } - + if(!empty($TSQLDate)) $TSQLMore[] = implode(' AND ', $TSQLDate); } else { $value = $this->dateToSQLDate($value); $TSQLMore[]=$sKey." LIKE '".$value."%'" ; - } } - - private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key) + + + /** + * @param $TSQLMore + * @param $value + * @param $TParam + * @param $sKey + * @param $key + * @return bool + */ + private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key) { if($value==-1) return false; @@ -363,7 +410,7 @@ class Listview $TTotal[$field]=count($this->TTotalTmp[$targetField]); } else { - $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]); + $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]); } } diff --git a/htdocs/inventory/list.php b/htdocs/inventory/list.php index 2fb1a2b7f31..23d25913ccd 100644 --- a/htdocs/inventory/list.php +++ b/htdocs/inventory/list.php @@ -43,7 +43,7 @@ llxHeader('',$langs->trans('inventoryListTitle'),'',''); echo '
    '; $inventory = new Inventory($db); -$list = new ListView($db,'listInventory'); +$list = new ListView($db, 'listInventory'); $THide = array('label','title'); From 2fc74b496278394b4b5bca76aa13b5b4d811a04c Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 25 Mar 2017 18:53:14 +0100 Subject: [PATCH 030/505] Refactoring class --- htdocs/core/class/listview.class.php | 685 +++++++++++++++------------ htdocs/inventory/list.php | 54 +-- 2 files changed, 420 insertions(+), 319 deletions(-) diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 11a948472e4..38645dbca0a 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -200,52 +200,51 @@ class Listview } else { - if(strpos($value,'%')===false) $value = '%'.$value.'%'; - $TSQLMore[]=$sKey." LIKE '".addslashes($value)."'" ; + if(strpos($value,'%')===false) $value = '%'.$value.'%'; + $TSQLMore[]=$sKey." LIKE '".addslashes($value)."'" ; } return true; } - private function search($sql,&$TParam) { - + + /** + * @param $sql + * @param $TParam + * @return string + */ + private function search($sql, &$TParam) + { $ListPOST = GETPOST('Listview'); - if(!empty($ListPOST[$this->id]['search'])) { + if(!empty($ListPOST[$this->id]['search'])) + { $sqlGROUPBY=''; - if(strpos($sql,'GROUP BY')!==false) { //TODO regex + if(strpos($sql,'GROUP BY')!==false) + { list($sql, $sqlGROUPBY) = explode('GROUP BY', $sql); } - if(strpos($sql,'WHERE ')===false)$sql.=' WHERE 1 '; //TODO regex - //TODO $value = GETPOST('Listview_'.$this->id.'_search_'.$key) ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'month'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'day'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'year') ) : ''; + if(strpos($sql,'WHERE ')===false) $sql.=' WHERE 1 '; - foreach($ListPOST[$this->id]['search'] as $key=>$value) + foreach($ListPOST[$this->id]['search'] as $key => $value) { $TsKey = $this->getSearchKey($key, $TParam); - - //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($allow_is_null && !empty($ListPOST[$this->id]['search_on_null'][$key])) { $TSQLMore[] = $sKey.' IS NULL '; - $search_on_null = true; - $value = ''; } - elseif($allow_is_null) + + // Do not use empty() function, statut 0 exist + if($value != '') { - 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); @@ -265,15 +264,18 @@ class Listview } if($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY; - } - return $sql; } - public function render($sql,$TParam=array()) { - + /** + * @param $sql + * @param array $TParam + * @return string + */ + public function render($sql, $TParam=array()) + { $THeader=array(); $TField=array(); @@ -286,11 +288,16 @@ class Listview list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam); - return $this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam); - + return $this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam); } - private function setSearch(&$THeader, &$TParam) { + /** + * @param $THeader + * @param $TParam + * @return array + */ + private function setSearch(&$THeader, &$TParam) + { global $langs, $form; if(empty($TParam['search'])) return array(); @@ -299,32 +306,33 @@ class Listview $nb_search_in_bar = 0; - if(!empty($TParam['search'])) { - foreach($THeader as $key=>$libelle) { // init + if(!empty($TParam['search'])) + { + foreach($THeader as $key => $libelle) + { if(empty($TSearch[$key]))$TSearch[$key]=''; } } $ListPOST = GETPOST('Listview'); - - foreach($TParam['search'] as $key=>$param_search) { - + foreach($TParam['search'] as $key => $param_search) + { $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)) { + if(is_array($typeRecherche)) + { $fsearch=$form->selectarray('Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,1); } - else if($typeRecherche==='calendar') { - + else if($typeRecherche==='calendar') + { $value = GETPOST('Listview_'.$this->id.'_search_'.$key) ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'month'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'day'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'year') ) : ''; $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') { - + else if($typeRecherche==='calendars') + { $value_start = GETPOST('Listview_'.$this->id.'_search_'.$key.'_start') ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startmonth'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startday'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startyear') ) : ''; $value_end = GETPOST('Listview_'.$this->id.'_search_'.$key.'_end') ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endmonth'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endday'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endyear') ) : ''; @@ -332,96 +340,113 @@ class Listview . $form->select_date($value_end, 'Listview_'.$this->id.'_search_'.$key.'_end',0, 0, 1, "", 1, 0, 1); } - else if(is_string($typeRecherche)) { + else if(is_string($typeRecherche)) + { $fsearch=$TParam['search'][$key]; } - else { + else + { $fsearch=''; } - if(!empty($param_search['allow_is_null'])) { + if(!empty($param_search['allow_is_null'])) + { $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])) { + if(!empty($THeader[$key])) + { $TSearch[$key] = $fsearch; $nb_search_in_bar++; } - else { + else + { $label = !empty($TParam['title'][$key]) ? $TParam['title'][$key] : $key ; $TParam['list']['head_search'].='
    '.$libelle.' '.$fsearch.'
    '; } - } $search_button = ' '.img_search().''; - if(!empty($TParam['list']['head_search'])) { + if(!empty($TParam['list']['head_search'])) + { $TParam['list']['head_search']='
    '.$search_button.'
    '.$TParam['list']['head_search']; } - if($nb_search_in_bar>0) { + if($nb_search_in_bar>0) + { end($TSearch); list($key,$v) = each($TSearch); $TSearch[$key].=$search_button; } - else{ + else + { $TSearch=array(); } return $TSearch; } - /* - * Function analysant et totalisant une colonne - * Supporté : sum, average - */ - private function get_total(&$TField, &$TParam) { + /** + * Function to analyse and calculate the total from a column + * + * @param $TField + * @param $TParam + * @return array + */ + private function get_total(&$TField, &$TParam) + { $TTotal=$TTotalGroup=array(); - if(!empty($TParam['math']) && !empty($TField[0])) { - - foreach($TField[0] as $field=>$value) { + if(!empty($TParam['math']) && !empty($TField[0])) + { + foreach($TField[0] as $field=>$value) + { $TTotal[$field]=''; $TTotalGroup[$field] = ''; } - foreach($TParam['math'] as $field=>$typeMath){ - - if(is_array($typeMath)) { + foreach($TParam['math'] as $field=>$typeMath) + { + if(is_array($typeMath)) + { $targetField = $typeMath[1]; $typeMath = $typeMath[0]; } - else { + else + { $targetField = $field; } - if($typeMath == 'groupsum') { + if($typeMath == 'groupsum') + { $TTotalGroup[$field] = array('target'=>$targetField, 'values'=> $this->TTotalTmp['@groupsum'][$targetField]); - } - else if($typeMath=='average') { + else if($typeMath=='average') + { $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]) / count($this->TTotalTmp[$targetField]); } - elseif($typeMath=='count') { + elseif($typeMath=='count') + { $TTotal[$field]=count($this->TTotalTmp[$targetField]); } - else { + else + { $TTotal[$field]=array_sum($this->TTotalTmp[$targetField]); } - } - - } return array($TTotal,$TTotalGroup); } - private function getJS() { + /** + * @return string + */ + private function getJS() + { $javaScript = ' + + + + + + Invoice #: ref; ?>
    + trans('Date') . ' : ' . dol_print_date($invoice->date, 'day'); ?>
    + trans('DateMaxPayment') . ' : ' . dol_print_date($invoice->date_validation, 'day'); ?> + + + + + + + + + + + + + + +
    + thirdparty->name; ?>
    + thirdparty->address; ?>
    + thirdparty->zip . ', ' . $invoice->thirdparty->town .' '. $invoice->thirdparty->country_code ; ?> +
    + +
    + + + + + + trans('PaymentConditionsShort'); ?> + + + + form_conditions_reglement('', $invoice->cond_reglement_id, 'none'); ?> + + + + + + + TOTAL + + + + + + + + + trans('AmountHT'); ?> + + + + total_ht, 1, '', 1, - 1, - 1, $conf->currency); ?> + + + + + + trans('AmountVAT'); ?> + + + + total_tva, 1, '', 1, - 1, - 1, $conf->currency); ?> + + + + + + trans('AmountTTC'); ?> + + + + total_ttc, 1, '', 1, - 1, - 1, $conf->currency); ?> + + + + + + + + Total: total_ttc, 1, '', 1, - 1, - 1, $conf->currency); ?> + + + + + + + + + + + + + + + + + + + + + diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php new file mode 100644 index 00000000000..9cc083051ec --- /dev/null +++ b/htdocs/stripe/config.php @@ -0,0 +1,36 @@ + + * Copyright (C) <2016> + * + * 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 . + */ + + +// Load Dolibarr environment +if (false === (@include '../main.inc.php')) { // From htdocs directory + require '../../main.inc.php'; // From "custom" directory +} + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/stripe/lib/stripe.lib.php'); +require_once('stripe/init.php'); + +//use \Stripe\Stripe as Stripe; +$stripe = array( + "secret_key" => $conf->global->TEST_SECRET_KEY, + "publishable_key" => $conf->global->TEST_PUBLISHABLE_KEY +); + +\Stripe\Stripe::setApiKey($stripe['secret_key']); +?> \ No newline at end of file diff --git a/htdocs/stripe/paymnt_link.php b/htdocs/stripe/paymnt_link.php new file mode 100644 index 00000000000..68adbf47a3c --- /dev/null +++ b/htdocs/stripe/paymnt_link.php @@ -0,0 +1,72 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + + +// Load Dolibarr environment +if (false === (@include '../main.inc.php')) { // From htdocs directory + require '../../main.inc.php'; // From "custom" directory +} +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + +// Load traductions files requiredby by page +$langs->load("mymodule"); +$langs->load("other"); + +// Get parameters +$id = GETPOST('id', 'int'); // For backward compatibility + +$object = new Facture($db); +// Load object +if ($id > 0 || ! empty($ref)) { + $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); +} + + + + +/*************************************************** +* VIEW +* +* Put here all code to build page +****************************************************/ + +llxHeader('','StripePaymentLink',''); + + +// Part to show record +if ($id) +{ + print load_fiche_titre($langs->trans("StripePaymentLink")); + + dol_fiche_head(); + + $link = $dolibarr_main_url_root . '/custom/stripe/checkout.php?source=invoice&ref=' . $object->ref; + print ''."\n"; + print ''; + // LIST_OF_TD_LABEL_FIELDS_VIEW + print '
    '.$langs->trans("PaymentLink").'
    '; + + dol_fiche_end(); + + + + +} + +llxFooter(); +$db->close(); From 04e119d7a67e9b679a9fedbb6977e405a4e00964 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 18 Apr 2017 07:03:57 +0200 Subject: [PATCH 069/505] New : Add search of accountancy code in main thirdparty search --- htdocs/societe/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 1799fadf9bd..ef162beb750 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -118,7 +118,9 @@ $fieldstosearchall = array( 's.nom'=>"ThirdPartyName", 's.name_alias'=>"AliasNameShort", 's.code_client'=>"CustomerCode", - "s.code_fournisseur"=>"SupplierCode", + 's.code_fournisseur'=>"SupplierCode", + 's.code_compta'=>"CustomerAccountancyCodeShort", + 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort", 's.email'=>"EMail", 's.url'=>"URL", 's.tva_intra'=>"VATIntra", From a52db08cd6d0620b6069b8e89e04722874c48cb6 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 18 Apr 2017 15:25:04 +0200 Subject: [PATCH 070/505] NEW : Add module resources import/export --- htdocs/core/class/ctyperesource.class.php | 500 ++++++++++++++++++++++ htdocs/core/modules/modResource.class.php | 163 +++---- htdocs/langs/en_US/resource.lang | 5 + 3 files changed, 561 insertions(+), 107 deletions(-) create mode 100644 htdocs/core/class/ctyperesource.class.php diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php new file mode 100644 index 00000000000..ee899ad6b86 --- /dev/null +++ b/htdocs/core/class/ctyperesource.class.php @@ -0,0 +1,500 @@ + + * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 resource/ctyperesource.class.php + * \ingroup resource + */ + +/** + * Class Ctyperesource + * + * Put here description of your class + * + * @see CommonObject + */ +class Ctyperesource +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'ctyperesource'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'c_type_resource'; + + /** + * @var CtyperesourceLine[] Lines + */ + public $lines = array(); + + /** + */ + + public $code; + public $label; + public $active; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } + + /** + * 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 create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'code,'; + $sql.= 'label'; + $sql.= 'active'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").','; + $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(! isset($this->active)?'NULL':$this->active); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * 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 fetch($id,$code='',$label='') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if ($id) $sql.= " WHERE t.id = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'"; + + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->code = $obj->code; + $this->label = $obj->label; + $this->active = $obj->active; + + + } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + /* + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + */ + + // $this->fetch_lines(); + + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield,$sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new self($this->db); + + $line->id = $obj->rowid; + + $line->code = $obj->code; + $line->label = $obj->label; + $line->active = $obj->active; + + + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * 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 update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' code = '.(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").','; + $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; + $sql .= ' active = '.(isset($this->active)?$this->active:"null"); + + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + if (!$error && !$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * 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 delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 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 + //$result=$this->call_trigger('MYOBJECT_DELETE',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + } + + // If you need to delete child tables to, you can insert them here + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * + * @return int New id of clone + */ + public function createFromClone($fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new Ctyperesource($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->code = ''; + $this->label = ''; + $this->active = ''; + } + +} + +/** + * Class CtyperesourceLine + */ +class CtyperesourceLine +{ + /** + * @var int ID + */ + public $id; + /** + * @var mixed Sample line property 1 + */ + + public $code; + public $label; + public $active; + + /** + * @var mixed Sample line property 2 + */ + +} diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index d3aa3405d0b..f6674bdcfd7 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -201,22 +201,6 @@ class modResource extends DolibarrModules $this->menu = 1; // This module add menu entries. They are coded into menu manager. - // Add here list of permission defined by - // an id, a label, a boolean and two constant strings. - // Example: - //// Permission id (must not be already used) - //$this->rights[$r][0] = 2000; - //// Permission label - //$this->rights[$r][1] = 'Permision label'; - //// Permission by default for new user (0/1) - //$this->rights[$r][3] = 0; - //// In php code, permission will be checked by test - //// if ($user->rights->permkey->level1->level2) - //$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'; - //$r++; // Main menu entries $this->menu = array(); // List of menus to add $r = 0; @@ -267,98 +251,63 @@ class modResource extends DolibarrModules 'user'=> 0 ); - // Exports - $r = 1; - // Example: - //$this->export_code[$r]=$this->rights_class.'_'.$r; - //// Translation key (used only if key ExportDataset_xxx_z not found) - //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; - //// Condition to show export in list (ie: '$user->id==3'). - //// Set to 1 to always show when module is enabled. - //$this->export_enabled[$r]='1'; - //$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.cp'=>'Zip', - // 's.ville'=>'Town', - // 's.fk_pays'=>'Country', - // 's.tel'=>'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.cp'=>'company', - // 's.ville'=>'company', - // 's.fk_pays'=>'company', - // 's.tel'=>'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'; - //$r++; + // Exports + //-------- + $r=0; + + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("resource","read")); + $this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification"); + $this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text'); + $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); + $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; + $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource',1).')'; + + + // Imports + //-------- + $r=0; + + // Import list of third parties and attributes + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]='ImportDataset_resource_1'; + $this->import_icon[$r]='resource'; + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation'); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity = ".$conf->entity; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r]=array( + 'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'), + ); + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); + $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); + $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionnary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); + $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); + } /** diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang index f95121db351..5a907f6ba23 100644 --- a/htdocs/langs/en_US/resource.lang +++ b/htdocs/langs/en_US/resource.lang @@ -29,3 +29,8 @@ RessourceSuccessfullyDeleted=Resource successfully deleted DictionaryResourceType=Type of resources SelectResource=Select resource + +IdResource=Id resource +AssetNumber=Serial number +ResourceTypeCode=Resource type code +ImportDataset_resource_1=Resources From 4efb1ba23a2193df98529da643a8848d30ffbdf7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 18 Apr 2017 15:27:18 +0200 Subject: [PATCH 071/505] update credentials --- htdocs/core/class/ctyperesource.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index ee899ad6b86..553c0f0d0cd 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -1,9 +1,8 @@ * Copyright (C) 2014-2016 Juanjo Menent - * Copyright (C) 2015 Florian Henry + * Copyright (C) 2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 From 433b9e6fe17840ba401415bff7d4f62d1200cec0 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 18 Apr 2017 16:22:39 +0200 Subject: [PATCH 072/505] Fix typo in en_US admin tag --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be60fc5db7c..068e44d920d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -286,7 +286,7 @@ FindPackageFromWebSite=Find a package that provides feature you want (for exampl DownloadPackageFromWebSite=Download package (for example from official web site %s). UnpackPackageInDolibarrRoot=Unpack package files into Dolibarr server directory dedicated to Dolibarr: %s UnpackPackageInModulesRoot=Unpack package files into Dolibarr server directory dedicated to modules: %s -oiSetupIsReadyForUse=Module deployement is finished. You must however enable and setup the module in your application by going on the page to setup modules: %s. +SetupIsReadyForUse=Module deployement is finished. You must however enable and setup the module in your application by going on the page to setup modules: %s. NotExistsDirect=The alternative root directory is not defined.
    InfDirAlt=Since version 3 it is possible to define an alternative root directory.This allows you to store, same place, plug-ins and custom templates.
    Just create a directory at the root of Dolibarr (eg: custom).
    InfDirExample=
    Then declare it in the file conf.php
    $dolibarr_main_url_root_alt='http://myserver/custom'
    $dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
    *These lines are commented with "#", to uncomment only remove the character. From 8bb7f858d96c7eca0ab038a760cac031732e22c7 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Apr 2017 16:47:06 +0200 Subject: [PATCH 073/505] 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 d89a89f8ea5730171c1b84ff3b369d0d44c9ec43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 17:03:34 +0200 Subject: [PATCH 074/505] Fix error message --- htdocs/expedition/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 29f2b7fab48..0077338aae5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1246,8 +1246,11 @@ if ($action == 'create') print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if ($warehouseObject) + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) { + $warehouseObject=new Entrepot($db); + $warehouseObject->fetch($warehouse_selected_id); print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); } else From 50210d0dd6dfec45185770d60a047e7fece7015f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 17:04:56 +0200 Subject: [PATCH 075/505] NEW Add tooltip help on shipment weight and volume calculation --- htdocs/expedition/card.php | 30 +++++++++++++++++++----------- htdocs/langs/en_US/products.lang | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c7893aefd2f..cbe602f7313 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -726,7 +726,9 @@ if ($action == 'create') print ''; print $langs->trans("Weight"); print ' '; - print $formproduct->select_measuring_units("weight_units","weight",GETPOST('weight_units','int')); + $text=$formproduct->select_measuring_units("weight_units","weight",GETPOST('weight_units','int')); + $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + print $form->textwithpicto($text, $htmltext); print ''; // Dim print ''; @@ -735,7 +737,9 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - print $formproduct->select_measuring_units("size_units","size"); + $text=$formproduct->select_measuring_units("size_units","size"); + $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + print $form->textwithpicto($text, $htmltext); print ''; // Delivery method @@ -865,7 +869,7 @@ if ($action == 'create') if (! empty($line->date_start)) $type=1; if (! empty($line->date_end)) $type=1; - print "\n"; + print ''."\n"; // Product label if ($line->fk_product > 0) // If predefined product @@ -1096,10 +1100,10 @@ if ($action == 'create') $nbofsuggested++; } } + $tmpwarehouseObject=new Entrepot($db); foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock { - $warehouseObject=new Entrepot($db); - $warehouseObject->fetch($warehouse_id); + $tmpwarehouseObject->fetch($warehouse_id); if ($stock_warehouse->real > 0) { $stock = + $stock_warehouse->real; // Convert it to number @@ -1122,7 +1126,7 @@ if ($action == 'create') print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print $warehouseObject->getNomUrl(0).' '; + print $tmpwarehouseObject->getNomUrl(0).' '; print ''; print '('.$stock.')'; @@ -1158,7 +1162,7 @@ if ($action == 'create') { $img=img_warning($langs->trans("StockTooLow")); } - print ""; + print ''; print "      -> ".$value['fullpath']." (".$value['nb'].") ".$value['nb_total']."   @@ -1175,7 +1179,7 @@ if ($action == 'create') $subj=0; print ''; - $warehouseObject=new Entrepot($db); + $tmpwarehouseObject=new Entrepot($db); $productlotObject=new Productlot($db); // Define nb of lines suggested for this order line $nbofsuggested=0; @@ -1190,7 +1194,7 @@ if ($action == 'create') } foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { - $warehouseObject->fetch($warehouse_id); + $tmpwarehouseObject->fetch($warehouse_id); if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { foreach ($stock_warehouse->detail_batch as $dbatch) { @@ -1203,7 +1207,7 @@ if ($action == 'create') print ''; - print $warehouseObject->getNomUrl(0).' / '; + print $tmpwarehouseObject->getNomUrl(0).' / '; print ''; print ''; @@ -1223,6 +1227,7 @@ if ($action == 'create') } } } + } if ($subj == 0) // Line not shown yet, we show it { @@ -1246,8 +1251,11 @@ if ($action == 'create') print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if ($warehouseObject) + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) { + $warehouseObject=new Entrepot($db); + $warehouseObject->fetch($warehouse_selected_id); print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); } else diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 48ced509c47..0ab21cae322 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -198,6 +198,7 @@ MultipriceRules=Price segment rules UseMultipriceRules=Use price segment rules (defined into product module setup) to autocalculate prices of all other segment according to first segment PercentVariationOver=%% variation over %s PercentDiscountOver=%% discount over %s +KeepEmptyForAutoCalculation=Keep empty to have this calculated automatically from weight or volume of products ### composition fabrication Build=Produce ProductsMultiPrice=Products and prices for each price segment From cfc31e91e87064cf73931e18e3ff496da7a2ce27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 18:13:43 +0200 Subject: [PATCH 076/505] FIX overwrapping of weight/volume on rouget template --- .../expedition/doc/pdf_rouget.modules.php | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index dab925eef1d..d1697b767bd 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -69,19 +69,18 @@ class pdf_rouget extends ModelePdfExpedition // Define position of columns $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 76; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; $this->posxpuht=$this->page_largeur - $this->marge_droite; - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 130; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 100; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 70; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; - } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images @@ -344,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -459,16 +458,17 @@ class pdf_rouget extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=$object->lines[$i]->weight*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=$object->lines[$i]->volume*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?', ':'').$voltxt,'','C'); - + + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
    ':'').$voltxt, 0, 0, false, true, 'C'); + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
    ':'').$voltxt,'','C'); + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); @@ -479,27 +479,27 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) -{ + { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); - } + $nexY+=3; + if ($weighttxt && $voltxt) $nexY+=2; + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Passe espace entre les lignes - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -650,7 +650,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -658,20 +658,20 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); - } + } // Total Weight if ($totalWeighttoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalWeighttoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $index++; } if ($totalVolumetoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalVolumetoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $index++; } @@ -949,6 +949,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(230,230,230); $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(255,255,255); // Show sender name $pdf->SetXY($posx+2,$posy+3); From 529ae1fa92b4da7f3baae2cc3a13bfdb4f8f1dc4 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Wed, 19 Apr 2017 10:01:43 +0200 Subject: [PATCH 077/505] Update propal.class.php --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9aad218e66f..46c6a55cf2f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3135,7 +3135,7 @@ class Propal extends CommonObject { $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; - $line->product_ref='SPECIMEN'; + $line->product_ref='SPECIMEN'; } $this->lines[$xnbp]=$line; From 213e0d28708d7997e8eec1653dfc3a1db2fb27d6 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 19 Apr 2017 14:49:12 +0200 Subject: [PATCH 078/505] fix travis --- htdocs/core/class/ctyperesource.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 553c0f0d0cd..1de616210e4 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -154,7 +154,8 @@ class Ctyperesource * Load object in memory from the database * * @param int $id Id object - * @param string $ref Ref + * @param string $code code + * @param string $label Label * * @return int <0 if KO, 0 if not found, >0 if OK */ From b7f1e74f6f347697bb4b1e7efe3723cf0701f7d4 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 20 Apr 2017 10:27:44 +0200 Subject: [PATCH 079/505] New SITUATION_DISPLAY_DIFF_ON_PDF feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit allow to display or the progress situation percent value the diférential situation percent value --- htdocs/core/lib/pdf.lib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 282bdec690e..d1a5e64dce2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1808,8 +1808,17 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm } if (empty($reshook)) { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->situation_percent . '%'; + if ($object->lines[$i]->special_code == 3) return ''; + if (empty($hidedetails) || $hidedetails > 1) + { + if($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) + { + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); + $result = ($prev_progress - $object->lines[$i]->situation_percent) . '%'; + } + else + $result = $object->lines[$i]->situation_percent . '%'; + } } return $result; } From 1792ff2d3b77ef56e80fa23bb84a767dfb9b799a Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 21 Apr 2017 09:41:08 +0200 Subject: [PATCH 080/505] oups inverted value --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d1a5e64dce2..c490a2f66c5 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1814,7 +1814,7 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); - $result = ($prev_progress - $object->lines[$i]->situation_percent) . '%'; + $result = ( $object->lines[$i]->situation_percent - $prev_progress) . '%'; } else $result = $object->lines[$i]->situation_percent . '%'; From 54256773c558f5599a2111c6010fc1ab1a8f6335 Mon Sep 17 00:00:00 2001 From: hugome Date: Fri, 21 Apr 2017 10:27:48 +0200 Subject: [PATCH 081/505] FIX: length_accounta return variable name --- htdocs/core/lib/accounting.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 8ec0713b01a..4d32aa899b3 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -151,7 +151,7 @@ function length_accounta($accounta) if ($accounta < 0 || empty($accounta)) return ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; + if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; if (! empty($a)) { From 3b626b75c42a1ad6ce05b5dcbf650bdd0a72e0c5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 22 Apr 2017 06:58:44 +0200 Subject: [PATCH 082/505] Update works --- htdocs/{stripe => core}/lib/stripe.lib.php | 0 htdocs/core/modules/modStripe.class.php | 4 +- htdocs/stripe/checkout.php | 23 ++++--- htdocs/stripe/config.php | 25 ++++---- htdocs/stripe/lib/index.html | 0 htdocs/stripe/paymnt_link.php | 72 ---------------------- 6 files changed, 26 insertions(+), 98 deletions(-) rename htdocs/{stripe => core}/lib/stripe.lib.php (100%) delete mode 100644 htdocs/stripe/lib/index.html delete mode 100644 htdocs/stripe/paymnt_link.php diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/core/lib/stripe.lib.php similarity index 100% rename from htdocs/stripe/lib/stripe.lib.php rename to htdocs/core/lib/stripe.lib.php diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index 4b498629017..4f4b15fa0a4 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -73,8 +73,8 @@ class modStripe extends DolibarrModules // Dependencies $this->depends = array(); // 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->phpmin = array(4,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(2,6); // Minimum version of Dolibarr required by module + $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(5,0); // Minimum version of Dolibarr required by module $this->langfiles = array("stripe"); // Constants diff --git a/htdocs/stripe/checkout.php b/htdocs/stripe/checkout.php index 0989d55b76f..f7f547afae9 100644 --- a/htdocs/stripe/checkout.php +++ b/htdocs/stripe/checkout.php @@ -1,6 +1,6 @@ - * Copyright (C) <2016> SaaSprov.ma +/* Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017 Saasprov * * 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 @@ -16,12 +16,11 @@ * along with this program. If not, see . */ - +require '../main.inc.php'; + // Load Dolibarr environment - - -require_once('config.php'); -require_once('stripe/init.php'); +require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'); +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); define("NOLOGIN",1); define("NOCSRFCHECK",1); @@ -30,8 +29,8 @@ $langs->load("main"); $langs->load("other"); $langs->load("stripe"); -$SOURCE=GETPOST("source",'alpha'); -$ref=$REF=GETPOST('ref','alpha'); +$source=GETPOST("source",'alpha'); +$ref=GETPOST('ref','alpha'); $form = new Form($db); @@ -40,18 +39,18 @@ $form = new Form($db); * * @return void */ -function llxHeader() { } +function llxHeader() {} /** * Footer empty * * @return void */ -function llxFooter() { } +function llxFooter() {} $invoice = null; // Payment on customer invoice -if (GETPOST("source") == 'invoice') +if ($source == 'invoice') { $found=true; $langs->load("bills"); diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 9cc083051ec..78d394feb53 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -1,6 +1,6 @@ - * Copyright (C) <2016> +/* Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017 Saasprov * * 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 @@ -16,21 +16,22 @@ * along with this program. If not, see . */ +/** +* \file stripe/config.php +* \ingroup Stripe +* \brief Page to move config in api +*/ -// Load Dolibarr environment -if (false === (@include '../main.inc.php')) { // From htdocs directory - require '../../main.inc.php'; // From "custom" directory -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; dol_include_once('/stripe/lib/stripe.lib.php'); -require_once('stripe/init.php'); +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); -//use \Stripe\Stripe as Stripe; +//use \includes\stripe as stripe; $stripe = array( - "secret_key" => $conf->global->TEST_SECRET_KEY, - "publishable_key" => $conf->global->TEST_PUBLISHABLE_KEY + "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY ); -\Stripe\Stripe::setApiKey($stripe['secret_key']); -?> \ No newline at end of file +\includes\stripe::setApiKey($stripe['secret_key']); \ No newline at end of file diff --git a/htdocs/stripe/lib/index.html b/htdocs/stripe/lib/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/stripe/paymnt_link.php b/htdocs/stripe/paymnt_link.php deleted file mode 100644 index 68adbf47a3c..00000000000 --- a/htdocs/stripe/paymnt_link.php +++ /dev/null @@ -1,72 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * 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 . - */ - - -// Load Dolibarr environment -if (false === (@include '../main.inc.php')) { // From htdocs directory - require '../../main.inc.php'; // From "custom" directory -} -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - -// Load traductions files requiredby by page -$langs->load("mymodule"); -$langs->load("other"); - -// Get parameters -$id = GETPOST('id', 'int'); // For backward compatibility - -$object = new Facture($db); -// Load object -if ($id > 0 || ! empty($ref)) { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); -} - - - - -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ - -llxHeader('','StripePaymentLink',''); - - -// Part to show record -if ($id) -{ - print load_fiche_titre($langs->trans("StripePaymentLink")); - - dol_fiche_head(); - - $link = $dolibarr_main_url_root . '/custom/stripe/checkout.php?source=invoice&ref=' . $object->ref; - print ''."\n"; - print ''; - // LIST_OF_TD_LABEL_FIELDS_VIEW - print '
    '.$langs->trans("PaymentLink").'
    '; - - dol_fiche_end(); - - - - -} - -llxFooter(); -$db->close(); From fbdfbed02c0a77175846139c31ba5cc67e472f63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Apr 2017 02:44:38 +0200 Subject: [PATCH 083/505] Add code to prepare a generic payment solution --- htdocs/public/payment/index.php | 28 + htdocs/public/payment/newpayment.php | 1002 ++++++++++++++++++++++++++ htdocs/public/payment/paymentko.php | 146 ++++ htdocs/public/payment/paymentok.php | 308 ++++++++ 4 files changed, 1484 insertions(+) create mode 100644 htdocs/public/payment/index.php create mode 100644 htdocs/public/payment/newpayment.php create mode 100644 htdocs/public/payment/paymentko.php create mode 100644 htdocs/public/payment/paymentok.php diff --git a/htdocs/public/payment/index.php b/htdocs/public/payment/index.php new file mode 100644 index 00000000000..cc491b860d3 --- /dev/null +++ b/htdocs/public/payment/index.php @@ -0,0 +1,28 @@ + + * + * 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/public/payment/index.php + * \ingroup core + * \brief A redirect page to an error + * \author Laurent Destailleur + */ + +require '../../master.inc.php'; + +header("Location: ".DOL_URL_ROOT.'/public/error-404.php'); + diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php new file mode 100644 index 00000000000..4c4b6863aaa --- /dev/null +++ b/htdocs/public/payment/newpayment.php @@ -0,0 +1,1002 @@ + + * Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2009-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 . + * + * For test: https://developer.paypal.com/ + */ + +/** + * \file htdocs/public/payment/newpayment.php + * \ingroup core + * \brief File to offer a way to make a payment for a particular Dolibarr entity + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + +// Security check +//if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("errors"); + +// Input are: +// type ('invoice','order','contractline'), +// id (object id), +// amount (required if id is empty), +// tag (a free text, required if type is empty) +// currency (iso code) + +$suffix=GETPOST("suffix",'alpha'); +$amount=price2num(GETPOST("amount")); +if (! GETPOST("currency",'alpha')) $currency=$conf->currency; +else $currency=GETPOST("currency",'alpha'); + +if (! GETPOST("action")) +{ + if (! GETPOST("amount") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); + exit; + } + if (is_numeric($amount) && ! GETPOST("tag") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); + exit; + } + if (GETPOST("source") && ! GETPOST("ref")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); + exit; + } +} + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +$urlok=$urlwithroot.'/public/payment/paymentok.php?'; +$urlko=$urlwithroot.'/public/payment/paymentko.php?'; + +// Complete urls for post treatment +$SOURCE=GETPOST("source",'alpha'); +$ref=$REF=GETPOST('ref','alpha'); +$TAG=GETPOST("tag",'alpha'); +$FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations +$SECUREKEY=GETPOST("securekey"); // Secure key + +if (! empty($SOURCE)) +{ + $urlok.='source='.urlencode($SOURCE).'&'; + $urlko.='source='.urlencode($SOURCE).'&'; +} +if (! empty($REF)) +{ + $urlok.='ref='.urlencode($REF).'&'; + $urlko.='ref='.urlencode($REF).'&'; +} +if (! empty($TAG)) +{ + $urlok.='tag='.urlencode($TAG).'&'; + $urlko.='tag='.urlencode($TAG).'&'; +} +if (! empty($FULLTAG)) +{ + $urlok.='fulltag='.urlencode($FULLTAG).'&'; + $urlko.='fulltag='.urlencode($FULLTAG).'&'; +} +if (! empty($SECUREKEY)) +{ + $urlok.='securekey='.urlencode($SECUREKEY).'&'; + $urlko.='securekey='.urlencode($SECUREKEY).'&'; +} +if (! empty($entity)) +{ + $urlok.='entity='.urlencode($entity).'&'; + $urlko.='entity='.urlencode($entity).'&'; +} +$urlok=preg_replace('/&$/','',$urlok); // Remove last & +$urlko=preg_replace('/&$/','',$urlko); // Remove last & + +$paymentmethod=array(); + +// Check parameters +if (! empty($conf->paypal->enabled)) +{ + $langs->load("paypal"); + + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; + + $PAYPAL_API_OK=""; + if ($urlok) $PAYPAL_API_OK=$urlok; + $PAYPAL_API_KO=""; + if ($urlko) $PAYPAL_API_KO=$urlko; + if (empty($PAYPAL_API_USER)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; + } + if (empty($PAYPAL_API_PASSWORD)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; + } + if (empty($PAYPAL_API_SIGNATURE)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; + } + + // Check security token + $valid=true; + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + else $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } + else + { + $token = $conf->global->PAYPAL_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; + + if (! $valid) + { + print '
    Bad value for key.
    '; + //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + exit; + } + else + { + $paymentmethod[]='paypal'; + } + } +} +if (! empty($conf->paybox->enabled)) +{ + $langs->load("paybox"); + +} +// TODO Add check of other payment mode + + +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + + +/* + * Actions + */ + +if (GETPOST("action") == 'dopayment') +{ + if (GETPOST('paymentmethod') == 'paypal') + { + $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); + $PAYPAL_PAYMENT_TYPE='Sale'; + + $shipToName=GETPOST("shipToName"); + $shipToStreet=GETPOST("shipToStreet"); + $shipToCity=GETPOST("shipToCity"); + $shipToState=GETPOST("shipToState"); + $shipToCountryCode=GETPOST("shipToCountryCode"); + $shipToZip=GETPOST("shipToZip"); + $shipToStreet2=GETPOST("shipToStreet2"); + $phoneNum=GETPOST("phoneNum"); + $email=GETPOST("email"); + $desc=GETPOST("desc"); + + $mesg=''; + if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); + elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + + //var_dump($_POST); + if (empty($mesg)) + { + dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); + + // Other + $PAYPAL_API_DEVISE="USD"; + //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; + //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; + if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; + + dol_syslog("Submit Paypal form", LOG_DEBUG); + dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); + //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files + dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); + dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); + dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); + dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); + dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); + dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + dol_syslog("shipToName: $shipToName", LOG_DEBUG); + dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); + dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); + dol_syslog("shipToState: $shipToState", LOG_DEBUG); + dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); + dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); + dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); + dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); + dol_syslog("email: $email", LOG_DEBUG); + dol_syslog("desc: $desc", LOG_DEBUG); + + dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO + //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; + //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; + //$_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE; + + // A redirect is added if API call successfull + print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + + exit; + } + } +} + + +/* + * View + */ + +llxHeaderPaypal($langs->trans("PaymentForm")); + +if (! empty($conf->paypal->enabled)) +{ + if (! empty($PAYPAL_API_SANDBOX)) + { + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning'); + } + + // Common variables + $creditor=$mysoc->name; + $paramcreditor='PAYPAL_CREDITOR_'.$suffix; + if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; + else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; +} + +print ''."\n"; +print '
    '."\n"; +print '
    '."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; +if (! empty($conf->paypal->enabled)) +{ + print ''."\n"; + print ''."\n"; + print ''."\n"; +} +print ''."\n"; +print ''."\n"; +print "\n"; + +print ''."\n"; + +// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo) +$width=0; +// Define logo and logosmall +$logosmall=$mysoc->logo_small; +$logo=$mysoc->logo; +$paramlogo='PAYMENT_LOGO_'.$suffix; +if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; +else if (! empty($conf->global->PAYMENT_LOGO)) $logosmall=$conf->global->PAYBOX_LOGO; +//print ''."\n"; +// Define urllogo +$urllogo=''; +if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('thumbs/'.$logosmall); +} +elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($logo); + $width=96; +} +// Output html code for logo +if ($urllogo) +{ + print ''; + print ''; + print ''."\n"; +} + +// Output introduction text +$text=''; +if (! empty($conf->global->PAYPAL_NEWFORM_TEXT)) +{ + $langs->load("members"); + if (preg_match('/^\((.*)\)$/',$conf->global->PAYPAL_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
    \n"; + else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."
    \n"; + $text=''."\n"; +} +if (empty($text)) +{ + $text.=''."\n"; + $text.=''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; + +print '

    '.$text.'

    '.$langs->trans("WelcomeOnPaymentPage").'

    '.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

    '; +print ''; +print ''."\n"; + +$found=false; +$error=0; +$var=false; + +// Free payment +if (! GETPOST("source") && $valid) +{ + $found=true; + $tag=GETPOST("tag"); + $fulltag=$tag; + + // Creditor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum + // as they don't exists (buyer is unknown, tag is free). +} + + +// Payment on customer order +if (GETPOST("source") == 'order' && $valid) +{ + $found=true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order=new Commande($db); + $result=$order->fetch('',$ref); + if ($result < 0) + { + $mesg=$order->error; + $error++; + } + else + { + $result=$order->fetch_thirdparty($order->socid); + } + + $amount=$order->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; + //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$order->thirdparty->name; + $shipToStreet=$order->thirdparty->address; + $shipToCity=$order->thirdparty->town; + $shipToState=$order->thirdparty->state_code; + $shipToCountryCode=$order->thirdparty->country_code; + $shipToZip=$order->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$order->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + + +// Payment on customer invoice +if (GETPOST("source") == 'invoice' && $valid) +{ + $found=true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice=new Facture($db); + $result=$invoice->fetch('',$ref); + if ($result < 0) + { + $mesg=$invoice->error; + $error++; + } + else + { + $result=$invoice->fetch_thirdparty($invoice->socid); + } + + $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; + //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$invoice->thirdparty->name; + $shipToStreet=$invoice->thirdparty->address; + $shipToCity=$invoice->thirdparty->town; + $shipToState=$invoice->thirdparty->state_code; + $shipToCountryCode=$invoice->thirdparty->country_code; + $shipToZip=$invoice->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$invoice->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on contract line +if (GETPOST("source") == 'contractline' && $valid) +{ + $found=true; + $langs->load("contracts"); + + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + + $contractline=new ContratLigne($db); + $result=$contractline->fetch('',$ref); + if ($result < 0) + { + $mesg=$contractline->error; + $error++; + } + else + { + if ($contractline->fk_contrat > 0) + { + $contract=new Contrat($db); + $result=$contract->fetch($contractline->fk_contrat); + if ($result > 0) + { + $result=$contract->fetch_thirdparty($contract->socid); + } + else + { + $mesg=$contract->error; + $error++; + } + } + else + { + $mesg='ErrorRecordNotFound'; + $error++; + } + } + + $amount=$contractline->total_ttc; + if ($contractline->fk_product) + { + $product=new Product($db); + $result=$product->fetch($contractline->fk_product); + + // We define price for product (TODO Put this in a method in product class) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; + $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; + $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; + } + else + { + $pu_ht = $product->price; + $pu_ttc = $product->price_ttc; + $price_base_type = $product->price_base_type; + } + + $amount=$pu_ttc; + if (empty($amount)) + { + dol_print_error('','ErrorNoPriceDefinedForThisProduct'); + exit; + } + } + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + $qty=1; + if (GETPOST('qty')) $qty=GETPOST('qty'); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Quantity + + $label=$langs->trans("Quantity"); + $qty=1; + $duration=''; + if ($contractline->fk_product) + { + if ($product->isService() && $product->duration_value > 0) + { + $label=$langs->trans("Duration"); + + // TODO Put this in a global method + if ($product->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears")); + } + else + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear")); + } + $duration=$product->duration_value.' '.$dur[$product->duration_unit]; + } + } + print ''; + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$contract->thirdparty->name; + $shipToStreet=$contract->thirdparty->address; + $shipToCity=$contract->thirdparty->town; + $shipToState=$contract->thirdparty->state_code; + $shipToCountryCode=$contract->thirdparty->country_code; + $shipToZip=$contract->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$contract->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on member subscription +if (GETPOST("source") == 'membersubscription' && $valid) +{ + $found=true; + $langs->load("members"); + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $member=new Adherent($db); + $result=$member->fetch('',$ref); + if ($result < 0) + { + $mesg=$member->error; + $error++; + } + else + { + $subscription=new Subscription($db); + } + + $amount=$subscription->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + if ($member->last_subscription_date || $member->last_subscription_amount) + { + // Last subscription date + + print ''."\n"; + + // Last subscription amount + + print ''."\n"; + + if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + } + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$member->getFullName($langs); + $shipToStreet=$member->address; + $shipToCity=$member->town; + $shipToState=$member->state_code; + $shipToCountryCode=$member->country_code; + $shipToZip=$member->zip; + $shipToStreet2=''; + $phoneNum=$member->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print ''."\n"; +} + + + + +if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); + +if ($mesg) print ''."\n"; + +print '
    '.$langs->trans("ThisIsInformationOnPayment").' :
    '.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
    '.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
    '.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
    '.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
    '.$langs->trans("ThirdParty"); + print ''.$order->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; + print '
    '.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
    '.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
    '.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
    '.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
    '.$langs->trans("ThirdParty"); + print ''.$invoice->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; + print '
    '.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
    '.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
    '.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
    '.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
    '.$langs->trans("ThirdParty"); + print ''.$contract->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).''; + if ($contractline->fk_product) + { + $text.='
    '.$product->ref.($product->label?' - '.$product->label:''); + } + if ($contractline->description) $text.='
    '.dol_htmlentitiesbr($contractline->description); + //if ($contractline->date_fin_validite) { + // $text.='
    '.$langs->trans("DateEndPlanned").': '; + // $text.=dol_print_date($contractline->date_fin_validite); + //} + if ($contractline->date_fin_validite) + { + $text.='
    '.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); + } + + print '
    '.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
    '.$label.''.($duration?$duration:$qty).''; + print ''; + print '
    '.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
    '.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
    '.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
    '.$langs->trans("Member"); + print ''; + if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe; + else print $member->getFullName($langs); + print ''; + + // Object + + $text=''.$langs->trans("PaymentSubscription").''; + print '
    '.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
    '.$langs->trans("LastSubscriptionDate"); + print ''.dol_print_date($member->last_subscription_date,'day'); + print '
    '.$langs->trans("LastSubscriptionAmount"); + print ''.price($member->last_subscription_amount); + print '
    '.$langs->trans("Amount"); + if (empty($amount)) + { + print ' ('.$langs->trans("ToComplete"); + if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").''; + print ')'; + } + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + $valtoshow=GETPOST("newamount",'int'); + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''; + print ''; + } + else { + $valtoshow=$amount; + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''.price($valtoshow).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
    '.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '

    '.$mesg.'
    '."\n"; +print "\n"; + +if ($found && ! $error) // We are in a management option and no error +{ + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '
    '; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + print '
    '; + } +} +else +{ + dol_print_error_email('ERRORNEWPAYMENTPAYPAL'); +} + +print '
    '."\n"; +print '
    '."\n"; +print '
    '."\n"; +print '
    '; + + +html_print_paypal_footer($mysoc,$langs); + +llxFooterPaypal(); + +$db->close(); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php new file mode 100644 index 00000000000..70dac3c960b --- /dev/null +++ b/htdocs/public/payment/paymentko.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 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 . + */ + +/** + * \file htdocs/public/payment/paymentko.php + * \ingroup core + * \brief File to show page after a failed payment. + * This page is called by payment system with url provided to it competed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + + +/* + * View + */ + +dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + + +// Send an email +if (! empty($conf->paypal->enabled)) +{ + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentFailed"); + $content=$langs->transnoentitiesnoconv("NewPaypalPaymentFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } +} + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show ko message +print ''."\n"; +print '
    '."\n"; +print $langs->trans("YourPaymentHasNotBeenRecorded")."

    "; + +if (! empty($conf->global->PAYPAL_MESSAGE_KO)) print $conf->global->PAYPAL_MESSAGE_KO; +print "\n
    \n"; + + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php new file mode 100644 index 00000000000..ce3fcd8bb29 --- /dev/null +++ b/htdocs/public/payment/paymentok.php @@ -0,0 +1,308 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 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 . + */ + +/** + * \file htdocs/public/payment/paymentok.php + * \ingroup core + * \brief File to show page after a successful payment + * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +// Security check +//if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +// Clean parameters +if (! empty($conf->paypal->enabled)) +{ + $PAYPAL_API_USER=""; + if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; + $PAYPAL_API_PASSWORD=""; + if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; + $PAYPAL_API_SIGNATURE=""; + if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; + $PAYPAL_API_SANDBOX=""; + if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + $PAYPAL_API_OK=""; + if ($urlok) $PAYPAL_API_OK=$urlok; + $PAYPAL_API_KO=""; + if ($urlko) $PAYPAL_API_KO=$urlko; + if (empty($PAYPAL_API_USER)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; + } + if (empty($PAYPAL_API_PASSWORD)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; + } + if (empty($PAYPAL_API_SIGNATURE)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; + } +} + +$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + +/* + * View + */ + +dol_syslog("Callback url when a payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show message +print ''."\n"; +print '
    '."\n"; + +if (! empty($conf->paypal->enabled)) +{ + if ($PAYPALTOKEN) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + dol_syslog("Call paymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); + + + // Validate record + if (! empty($paymentType)) + { + dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_payment'); + $resArray=getDetails($token); + //var_dump($resarray); + + dol_syslog("We call DoExpressCheckoutPayment token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment'); + $resArray=confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag); + + $ack = strtoupper($resArray["ACK"]); + if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + { + $object = new stdClass(); + + $object->source = $source; + $object->ref = $ref; + $object->payerID = $payerID; + $object->fulltag = $fulltag; + $object->resArray = $resArray; + + // resArray was built from a string like that + // TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None + $PAYMENTSTATUS=urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed' + $TRANSACTIONID=urldecode($resArray["TRANSACTIONID"]); + $TAXAMT=urldecode($resArray["TAXAMT"]); + $NOTE=urldecode($resArray["NOTE"]); + + print $langs->trans("YourPaymentHasBeenRecorded")."
    \n"; + print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

    \n"; + if (! empty($conf->global->PAYPAL_MESSAGE_OK)) print $conf->global->PAYPAL_MESSAGE_OK; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"); + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + $content=""; + if (! empty($tmptag['MEM'])) + { + $langs->load("members"); + $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; + $content.=$langs->trans("PaymentSubscription")."
    \n"; + $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
    \n"; + $content.=$langs->trans("Link").': '.$url.''."
    \n"; + } + else + { + $content.=$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."
    \n"; + } + $content.="
    \n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
    \n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
    \n"; + $content.="tag=".$fulltag." token=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + else + { + //Display a user friendly Error on the page using any of the following error information returned by PayPal + $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); + $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); + $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); + $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); + + echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
    \n"; + echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
    \n"; + echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
    \n"; + echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
    \n"; + echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
    \n"; + + if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
    \n"; + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed"); + $content=""; + $content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\n"; + $content.="\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; + $content.="tag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + } + else + { + dol_print_error('','Session expired'); + } + } +} +else +{ + // No TOKEN parameter in URL + dol_print_error('','No TOKEN parameter in URL'); +} + +print "\n
    \n"; + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); From 0080821dc5b4a3c40f7f5ddf5b8cd12f267c4983 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Apr 2017 16:05:54 +0200 Subject: [PATCH 084/505] Fix no invoice if not a customer --- htdocs/comm/card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4d4d50a1979..d5d11941b23 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1030,11 +1030,14 @@ if ($id > 0) if (! empty($conf->commande->enabled)) { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; + if ($object->client != 0 && $object->client != 2) + { + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; + } + else print ''; } - - if ($object->client != 0) print ''; + if ($object->client != 0 && $object->client != 2) print ''; else print ''; } From ec59f08e419dc3c81df14ffcd5a71f231331b9ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 00:46:27 +0200 Subject: [PATCH 085/505] FIX extrafield css for boolean type --- htdocs/core/class/extrafields.class.php | 4 ++++ htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 673f069d1b3..def56c5203a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -728,6 +728,10 @@ class ExtraFields { $showsize='minwidth400imp'; } + elseif ($type == 'boolean') + { + $showsize=''; + } else { if (round($size) < 12) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index d20184c70b4..2143fc294c7 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -34,7 +34,7 @@ print '
    '; $extrafields->fetch_name_optionals_label($elementtype); print '
    '; -print ""; +print '
    '; print ''; print ''; From af56c85057c9201f7a6a10abf9f400a36b4aca6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 03:11:19 +0200 Subject: [PATCH 086/505] Fix perms on file --- .../swiftmailer/lib/swiftmailer_generate_mimes_config.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php old mode 100644 new mode 100755 From 65fec95458f17fdd87673fb737fabd2f04b4e5f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 03:15:03 +0200 Subject: [PATCH 087/505] Fix debian package --- build/debian/dolibarr.postinst | 2 +- build/debian/install.forced.php.install | 2 +- build/makepack-dolibarr.pl | 3 ++- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- htdocs/install/fileconf.php | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 4b946fda433..6ee2a89931f 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -61,7 +61,7 @@ apache_install() { # Enable dolibarr conf if which a2enconf >/dev/null 2>&1 ;then # a2enconf exists for ubuntu only - echo "Enable link for Apache config file with a3enconf" + echo "Enable link for Apache config file with a2enconf" a2enconf dolibarr else if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/dolibarr.conf ]; then diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 56eef3287a6..e55ffae138e 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -7,7 +7,7 @@ // $force_install_packager='deb'; -$force_install_noedit=2; +$force_install_noedit=1; $force_install_message='KeepDefaultValuesDeb'; #$force_install_main_data_root='/usr/share/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents'; diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c06d8f0730f..f465cf51234 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -509,7 +509,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; # Removed known external modules to avoid any error when packaging from env where external modules are tested - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom/*`; # For custom we want to keep dir + #$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \;`; # For custom we want to keep dir $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`; @@ -554,6 +554,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/.gitmodules`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 627fcfd6fd9..917760dc900 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; /** * Class to import Excel files */ -class Importxlsx extends ModeleImports +class ImportXlsx extends ModeleImports { var $db; var $datatoimport; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 2b8f57d9d3c..cdd639ad50b 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -45,13 +45,13 @@ dolibarr_install_syslog("--- fileconf: entering fileconf.php page"); // install.forced.php into directory htdocs/install (This is the case with some wizard // installer like DoliWamp, DoliMamp or DoliBuntu). // We first init "forced values" to nothing. -if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters +if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block vars specific to distrib, 2 to block all technical parameters if (! isset($force_install_type)) $force_install_type=''; if (! isset($force_install_dbserver)) $force_install_dbserver=''; if (! isset($force_install_port)) $force_install_port=''; if (! isset($force_install_database)) $force_install_database=''; -if (! isset($force_install_prefix)) $force_install_prefix=''; -if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; +if (! isset($force_install_prefix)) $force_install_prefix=''; +if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; @@ -324,7 +324,7 @@ if (! empty($force_install_message)) ?>
    '.$langs->trans("Position").'
    '; print ''; print ''; @@ -180,7 +179,7 @@ if (! empty($triggers)) print ''."\n"; } } diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 6e0a62610aa..17ccd64d000 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -245,7 +245,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) clearstatcache(); - $var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/action/doc/"); @@ -263,10 +262,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $classname = substr($file, 0, dol_strlen($file) -12); require_once $dir.'/'.$file; - $module = new $classname($db, new ActionComm($db)); + $module = new $classname($db, new ActionComm($db)); - - print "\n"; + print '\n'; print "\n"; @@ -338,8 +336,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print '
    '.$langs->trans("ActionsEvents").''; $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; $value=$conf->global->$key; - print ''; + print ''; print '
    "; print (empty($module->name)?$name:$module->name); print "

    '; } -$var=true; - print '
    '; print ''; @@ -380,7 +376,6 @@ if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) } // AGENDA_DEFAULT_FILTER_TYPE - print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").''."\n"; print ' '."\n"; @@ -389,7 +384,6 @@ $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AG print ''."\n"; // AGENDA_DEFAULT_FILTER_STATUS - print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").''."\n"; print ' '."\n"; @@ -398,7 +392,6 @@ $formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_ print ''."\n"; // AGENDA_DEFAULT_VIEW - print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_VIEW").''."\n"; print ' '."\n"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 98cecb2f44b..8ed1e3cd9ac 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -273,7 +273,6 @@ print "\n"; clearstatcache(); -$var = true; foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { @@ -305,8 +304,7 @@ foreach ($dirmodels as $reldir) $modulequalified = 0; if ($modulequalified) { - $var = ! $var; - print ''; + print ''; print(empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 8c29fe67a1c..ef22d8ecb4a 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2011-2016 Philippe Grand + * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -545,7 +545,6 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print ''.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").''; print "\n"; - $var=true; print ''; @@ -561,10 +560,9 @@ if ($action == 'edit' || $action == 'updateedit') print ''.$langs->trans("VATManagement").''.$langs->trans("Description").''; print ' '; print "\n"; - $var=true; - print ""; + print ""; print ''; print ""; print ""; @@ -573,7 +571,7 @@ if ($action == 'edit' || $action == 'updateedit') print "\n"; - print ""; + print ""; print ''; + print ''; + print ''; + print ''; + print ''; + + print '
    '; print ""; print ""; @@ -595,10 +593,9 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print ''; print "\n"; - $var=true; // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print ""; + print ""; print '
    '.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").' 
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."'; print ''; print ""; @@ -620,7 +617,7 @@ if ($action == 'edit' || $action == 'updateedit') print "\n"; - print ""; + print ""; print ''; + print ''; + print ''; + print ''; + + print '
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."'; print ""; print ""; @@ -639,11 +636,10 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print ''; print "\n"; - $var=true; // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print ""; + print ""; print ''; - print '
    '.$langs->transcountry("LocalTax2Management",$mysoc->country_code).''.$langs->trans("Description").' 
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."'; print ''; print ""; @@ -662,7 +658,7 @@ if ($action == 'edit' || $action == 'updateedit') print "\n"; - print ""; + print ""; print ''; print ''; print ''; + $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 '
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."'; print ""; print ""; @@ -696,7 +692,6 @@ else print '
    '; print ''; - $var=true; 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 '
    '.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
    '.$langs->trans("CompanyName").''; @@ -799,7 +794,6 @@ else print ''; print ''; print ''; - $var=true; // Managing Director(s) @@ -965,7 +959,6 @@ else print ''; print ''; print "\n"; - $var=true; print ''; print ''; print "\n"; - $var=true; - print ""; + print ""; print '\n"; $var=!$var; print ''; $var=!$var; @@ -150,7 +152,11 @@ print ''; -$var=true; +print '
    '.$langs->trans("CompanyIds").''.$langs->trans("Value").'
    '.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
    '.$langs->trans("FiscalMonthStart").''; @@ -983,10 +976,9 @@ else print ''.$langs->trans("VATManagement").''.$langs->trans("Description").' 
    global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."
    global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."'; print ""; print ""; @@ -995,7 +987,7 @@ else print "\n"; - print ""; + print ""; print ''; print "\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d430a8ea53b..7743da27c2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -253,17 +253,35 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); // Management of default values - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! isset($_GET['sortfield'])) // If we did a click on a field so sort, we do no appl default values { - $relativepathstring = preg_replace('/\.[a-z]+$/', '', $_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); - $relativepathstring=dol_string_nospecial($relativepathstring, '-'); - // $relativepathstring is now string that identify the page: '_societe_card', '_agenda_card', ... - $keyfordefaultvalue = 'MAIN_DEFAULT_FOR_'.$relativepathstring.'_'.$paramname; - global $conf; - if (isset($conf->global->$keyfordefaultvalue)) $out = $conf->global->$keyfordefaultvalue; + 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 + 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 (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + } + } } } elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; @@ -303,6 +321,11 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) global $user; $out = $user->id; } + elseif ($reg[1] == 'SUPERVISORID') + { + global $user; + $out = $user->fk_user; + } elseif ($reg[1] == 'ENTITYID') { global $conf; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af23343398b..1bfa5c0230c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -428,7 +428,7 @@ ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) TheKeyIsTheNameOfHtmlField=The key is the name of the html field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. -PageUrlForDefaultValues=You must enter here the relative url of the page. Examples: +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 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. diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index ebb99eb9807..61e51999479 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -180,7 +180,7 @@ if (! defined('NOREQUIREDB')) //print "Will work with data into entity instance number '".$conf->entity."'"; - // Here we read database (llx_const table and llx_default_values) and define $conf->global->XXX var. + // Here we read database (llx_const table) and define $conf->global->XXX var. $conf->setValues($db); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a3006d6ebcd..f23c8aca0b6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -376,7 +376,7 @@ class User extends CommonObject { if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) { - $user->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; + $this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; } } $this->db->free($resql); @@ -387,7 +387,7 @@ class User extends CommonObject return -3; } } - + return 1; } From 88515c306fdf759abd5cf97797db7b92a461b97f Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 28 Apr 2017 14:33:06 +0200 Subject: [PATCH 119/505] Fix Propal class doesn't have fetch_lines method yet --- htdocs/comm/propal/class/propal.class.php | 204 ++++++++++++---------- 1 file changed, 111 insertions(+), 93 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 46c6a55cf2f..348ca1938b0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1366,102 +1366,13 @@ class Propal extends CommonObject $this->lines = array(); /* - * Lignes propales liees a un produit ou non + * Lines */ - $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.= " 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,'; - $sql.= ' d.date_start, d.date_end'; - $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql.= " WHERE d.fk_propal = ".$this->id; - $sql.= " ORDER by d.rang"; - - $result = $this->db->query($sql); - if ($result) + $result=$this->fetch_lines(); + if ($result < 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafieldsline=new ExtraFields($this->db); - $line = new PropaleLigne($this->db); - $extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); - - $num = $this->db->num_rows($result); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($result); - - $line = new PropaleLigne($this->db); - - $line->rowid = $objp->rowid; //Deprecated - $line->id = $objp->rowid; - $line->fk_propal = $objp->fk_propal; - $line->fk_parent_line = $objp->fk_parent_line; - $line->product_type = $objp->product_type; - $line->label = $objp->custom_label; - $line->desc = $objp->description; // Description ligne - $line->qty = $objp->qty; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->subprice = $objp->subprice; - $line->fk_remise_except = $objp->fk_remise_except; - $line->remise_percent = $objp->remise_percent; - $line->price = $objp->price; // TODO deprecated - - $line->info_bits = $objp->info_bits; - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1 = $objp->total_localtax1; - $line->total_localtax2 = $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; - $line->special_code = $objp->special_code; - $line->rang = $objp->rang; - - $line->fk_product = $objp->fk_product; - - $line->ref = $objp->product_ref; // TODO deprecated - $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // TODO deprecated - $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; // Description produit - $line->fk_product_type = $objp->fk_product_type; - $line->fk_unit = $objp->fk_unit; - - $line->date_start = $this->db->jdate($objp->date_start); - $line->date_end = $this->db->jdate($objp->date_end); - - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - - $line->fetch_optionals($line->id,$extralabelsline); - - $this->lines[$i] = $line; - //dol_syslog("1 ".$line->fk_product); - //print "xx $i ".$this->lines[$i]->fk_product; - $i++; - } - $this->db->free($result); + return -3; } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - return 1; } @@ -1475,6 +1386,113 @@ class Propal extends CommonObject return -1; } } + + /** + * Load array lines + * + * @param int $only_product Return only physical products + * @return int <0 if KO, >0 if OK + */ + function fetch_lines($only_product=0) + { + $this->lines=array(); + + $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.= ' 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,'; + $sql.= ' d.date_start, d.date_end'; + $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)'; + $sql.= ' WHERE d.fk_propal = '.$this->id; + if ($only_product) $sql .= ' AND p.fk_product_type = 0'; + $sql.= ' ORDER by d.rang'; + + dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + $num = $this->db->num_rows($result); + + $i = 0; + while ($i < $num) + { + $objp = $this->db->fetch_object($result); + + $line = new PropaleLigne($this->db); + + $line->rowid = $objp->rowid; //Deprecated + $line->id = $objp->rowid; + $line->fk_propal = $objp->fk_propal; + $line->fk_parent_line = $objp->fk_parent_line; + $line->product_type = $objp->product_type; + $line->label = $objp->custom_label; + $line->desc = $objp->description; // Description ligne + $line->qty = $objp->qty; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->subprice = $objp->subprice; + $line->fk_remise_except = $objp->fk_remise_except; + $line->remise_percent = $objp->remise_percent; + $line->price = $objp->price; // TODO deprecated + + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $line->special_code = $objp->special_code; + $line->rang = $objp->rang; + + $line->fk_product = $objp->fk_product; + + $line->ref = $objp->product_ref; // TODO deprecated + $line->product_ref = $objp->product_ref; + $line->libelle = $objp->product_label; // TODO deprecated + $line->product_label = $objp->product_label; + $line->product_desc = $objp->product_desc; // Description produit + $line->fk_product_type = $objp->fk_product_type; + $line->fk_unit = $objp->fk_unit; + + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + + $line->fetch_optionals(); + + $this->lines[$i] = $line; + //dol_syslog("1 ".$line->fk_product); + //print "xx $i ".$this->lines[$i]->fk_product; + $i++; + } + + $this->db->free($result); + + return 1; + } + else + { + $this->error=$this->db->lasterror(); + return -3; + } + } /** * Update value of extrafields on the proposal From 058b43f342e895edde8fb483ca8686371430b9ff Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 28 Apr 2017 16:50:30 +0200 Subject: [PATCH 120/505] display the good value on pdf --- htdocs/core/lib/pdf.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c490a2f66c5..2fc447daffd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1853,7 +1853,7 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) - { + { if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); @@ -1861,9 +1861,16 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) if (empty($hidedetails) || $hidedetails > 1) { $total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); + if ($object->lines[$i]->situation_percent > 0 ) + { + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); + $progress = ( $object->lines[$i]->situation_percent - $prev_progress) /100; + $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); + } + else $result.=price($sign * $total_ht, 0, $outputlangs); - } } + } return $result; } From 2e6d865c7d07b48254228cba07e082d42a53ed28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Apr 2017 00:44:25 +0200 Subject: [PATCH 121/505] NEW Can define default values for create forms. NEW Can define default filters for list pages. NEW Can define default sort order for list pages. --- htdocs/admin/defaultvalues.php | 95 +++++++++++++++++++++++++------ htdocs/admin/dict.php | 2 +- htdocs/core/db/DoliDB.class.php | 17 ++++-- htdocs/core/lib/functions.lib.php | 53 ++++++++++++----- htdocs/langs/en_US/admin.lang | 4 +- htdocs/theme/eldy/style.css.php | 2 +- 6 files changed, 135 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 96fef57e7cf..8a9bd4f209b 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -56,6 +56,10 @@ $defaultvalue = GETPOST('defaultvalue'); $defaulturl=preg_replace('/^\//', '', $defaulturl); +$urlpage = GETPOST('urlpage'); +$key = GETPOST('key'); +$value = GETPOST('value'); + /* * Actions @@ -81,25 +85,51 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP } -if ($action == 'add' || (GETPOST('add') && $action != 'update')) +if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { $error=0; - if (empty($defaulturl)) + if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); - $error++; + if (empty($defaulturl)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($defaultkey)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } - if (empty($defaultkey)) + if (GETPOST('actionmodify')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors'); - $error++; + if (empty($urlpage)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($key)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } + if (! $error) { $db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + + if ($action == 'add' || (GETPOST('add') && $action != 'update')) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + } + if (GETPOST('actionmodify')) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; + $sql.= " WHERE rowid = ".$id; + } + $result = $db->query($sql); if ($result > 0) { @@ -176,6 +206,10 @@ $head=defaultvalues_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); +if ($mode == 'sortorder') +{ + print info_admin($langs->trans("WarningSettingSortOrder")).'
    '; +} print ''; print ''; @@ -189,8 +223,15 @@ 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); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); +if ($mode != 'sortorder') +{ + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} +else +{ + $texthelp='field or alias.field'; + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); if ($mode != 'sortorder') { @@ -270,9 +311,17 @@ if ($result) print '
    '; - print ''."\n"; - print ''."\n"; - + print ''."\n"; + + // Key + print ''."\n"; + // Value print ''; print ''; print "\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c8632f57772..125f913eb8d 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1306,10 +1306,10 @@ if ($id) if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); print ''; } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c63227e1601..9fc1739334c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -220,9 +220,9 @@ abstract class DoliDB implements Database /** * Define sort criteria of request * - * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' * @param 'ASC'|'DESC' $sortorder Sort order - * @return string String to provide syntax of a sort sql string + * @return string String to provide syntax of a sort sql string */ function order($sortfield=null,$sortorder=null) { @@ -230,18 +230,25 @@ abstract class DoliDB implements Database { $return=''; $fields=explode(',',$sortfield); + $orders=explode(',',$sortorder); + $i=0; foreach($fields as $val) { if (! $return) $return.=' ORDER BY '; - else $return.=','; + else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); + + $tmpsortorder = trim($orders[$i]); + // Only ASC and DESC values are valid SQL - if (strtoupper($sortorder) === 'ASC') { + if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; - } elseif (strtoupper($sortorder) === 'DESC') { + } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } + + $i++; } return $return; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7743da27c2d..0d54593f0db 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -246,16 +246,16 @@ function dol_shutdown() * @param mixed $options Options to pass to filter_var when $check is set to custom * @return string|string[] Value found (string or array), or '' if check fails */ -function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) +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 so sort, we do no appl 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])) + 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); @@ -268,18 +268,40 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; } } - // Management of default search_filters + // 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"]; + $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 (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + //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]; } } } @@ -3178,6 +3200,9 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $tag='th'; if ($thead==2) $tag='div'; + $tmpsortfield=explode(',',$sortfield); + $sortfield=trim($tmpsortfield[0]); + // If field is used as sort criteria we use a specific class // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; @@ -3192,13 +3217,13 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m if ($field != $sortfield) { - if ($sortorder == 'DESC') $out.= ''; - if ($sortorder == 'ASC' || ! $sortorder) $out.= ''; + if (preg_match('/^DESC/', $sortorder)) $out.= ''; + else $out.= ''; } else { - if ($sortorder == 'DESC' || ! $sortorder) $out.= ''; - if ($sortorder == 'ASC') $out.= ''; + if (preg_match('/^ASC/', $sortorder)) $out.= ''; + else $out.= ''; } } @@ -3227,12 +3252,12 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m } else { - if ($sortorder == 'DESC' ) { + if (preg_match('/^DESC/', $sortorder)) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",1).''; $sortimg.= ''.img_up("Z-A",0).''; } - if ($sortorder == 'ASC' ) { + if (preg_match('/^ASC/', $sortorder)) { //$out.= ''.img_down("A-Z",1).''; //$out.= ''.img_up("Z-A",0).''; $sortimg.= ''.img_down("A-Z",0).''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1bfa5c0230c..69c72fc7aad 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -427,11 +427,13 @@ WarningPHPMail=WARNING: Some email providers (like Yahoo) does not allow you to ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) -TheKeyIsTheNameOfHtmlField=The key is the name of the html field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. +TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. 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 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. +Field=Field # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f0e615f29ce..4d711599992 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -253,7 +253,7 @@ a.tab { font-weight: bold !important; } a:link, a:visited, a:hover, a:active { font-family: ; font-weight: normal; color: rgb(); text-decoration: none; } a:hover { text-decoration: underline; color: rgb(); } a.commonlink { color: rgb() !important; text-decoration: none; } - +th.liste_titre a div div:hover, th.liste_titre_sel a div div:hover { text-decoration: underline; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { background-color: #FFF; } From 05fe0d7fcdcefb15970d1a470e75c9e4187b54ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Apr 2017 01:01:12 +0200 Subject: [PATCH 122/505] Fix doxygen --- htdocs/includes/odtphp/Segment.php | 30 +++++++++++++++--------- htdocs/includes/odtphp/odf.php | 37 +++++++++++++++++++----------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 39761aa4d04..d8a14d09df9 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -1,14 +1,16 @@ xmlParsed; } + /** * Analyse the XML code in order to find children * - * @param string $xml + * @param string $xml Xml * @return Segment */ protected function _analyseChildren($xml) @@ -172,11 +177,14 @@ class Segment implements IteratorAggregate, Countable } return $this; } + /** * Assign a template variable to replace * - * @param string $key - * @param string $value + * @param string $key Key + * @param string $value Value + * @param string $encode Encode + * @param string $charset Charset * @throws SegmentException * @return Segment */ @@ -230,7 +238,7 @@ IMG; /** * Shortcut to retrieve a child * - * @param string $prop + * @param string $prop Prop * @return Segment * @throws SegmentException */ @@ -245,8 +253,8 @@ IMG; /** * Proxy for setVars * - * @param string $meth - * @param array $args + * @param string $meth Meth + * @param array $args Args * @return Segment */ public function __call($meth, $args) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index d052482845c..01633634705 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -1,16 +1,20 @@ {aaa} // instead of {aaa} so we should enhance this function. //print $key.'-'.$value.'-'.strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']).'
    '; - if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml , $tag) === false) { + if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml, $tag) === false) { //if (strpos($this->contentXml, '">'. $key . '') === false) { throw new OdfException("var $key not found in the document"); //} @@ -577,6 +583,7 @@ IMG; } else { + dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING); $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF); } @@ -642,7 +649,8 @@ IMG; /** * Returns a variable of configuration * - * @return string The requested variable of configuration + * @param string $configKey Config key + * @return string The requested variable of configuration */ public function getConfig($configKey) { @@ -678,7 +686,8 @@ IMG; /** * Empty the temporary working directory recursively - * @param $dir the temporary working directory + * + * @param string $dir The temporary working directory * @return void */ private function _rrmdir($dir) @@ -701,8 +710,8 @@ IMG; /** * return the value present on odt in [valuename][/valuename] * - * @param string $value name balise in the template - * @return string the value inside the balise + * @param string $valuename Balise in the template + * @return string The value inside the balise */ public function getvalue($valuename) { From 47089a4d550517aef1a166848151f9996cac641e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Apr 2017 07:04:34 +0200 Subject: [PATCH 123/505] Modle Stripe : Work in progress --- htdocs/core/lib/stripe.lib.php | 147 ---- htdocs/{ => public}/stripe/checkout.php | 31 +- htdocs/{ => public}/stripe/config.php | 6 +- htdocs/public/stripe/newpayment.php | 977 ------------------------ htdocs/public/stripe/paymentko.php | 115 --- htdocs/public/stripe/paymentok.php | 172 ----- htdocs/stripe/admin/stripe.php | 22 +- 7 files changed, 27 insertions(+), 1443 deletions(-) rename htdocs/{ => public}/stripe/checkout.php (94%) rename htdocs/{ => public}/stripe/config.php (88%) delete mode 100644 htdocs/public/stripe/newpayment.php delete mode 100644 htdocs/public/stripe/paymentko.php delete mode 100644 htdocs/public/stripe/paymentok.php diff --git a/htdocs/core/lib/stripe.lib.php b/htdocs/core/lib/stripe.lib.php index d2d138cc8b3..175df3554ce 100644 --- a/htdocs/core/lib/stripe.lib.php +++ b/htdocs/core/lib/stripe.lib.php @@ -229,153 +229,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f } -/** - * Create a redirect form to paybox form - * - * @param int $PRICE Price - * @param string $CURRENCY Currency - * @param string $EMAIL EMail - * @param string $urlok Url to go back if payment is OK - * @param string $urlko Url to go back if payment is KO - * @param string $TAG Tag - * @return int 1 if OK, -1 if ERROR - */ -function print_stripe_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) -{ - global $conf, $langs, $db; - - dol_syslog("Stripe.lib::print_paybox_redirect", LOG_DEBUG); - - // Clean parameters - $PBX_IDENTIFIANT="2"; // Identifiant pour v2 test - if (! empty($conf->global->PAYBOX_PBX_IDENTIFIANT)) $PBX_IDENTIFIANT=$conf->global->PAYBOX_PBX_IDENTIFIANT; - $IBS_SITE="1999888"; // Site test - if (! empty($conf->global->PAYBOX_IBS_SITE)) $IBS_SITE=$conf->global->PAYBOX_IBS_SITE; - $IBS_RANG="99"; // Rang test - if (! empty($conf->global->PAYBOX_IBS_RANG)) $IBS_RANG=$conf->global->PAYBOX_IBS_RANG; - $IBS_DEVISE="840"; // Currency (Dollar US by default) - if ($CURRENCY == 'EUR') $IBS_DEVISE="978"; - if ($CURRENCY == 'USD') $IBS_DEVISE="840"; - - $URLPAYBOX=""; - if ($conf->global->PAYBOX_CGI_URL_V1) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V1; - if ($conf->global->PAYBOX_CGI_URL_V2) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V2; - - if (empty($IBS_DEVISE)) - { - dol_print_error('',"Paybox setup param PAYBOX_IBS_DEVISE not defined"); - return -1; - } - if (empty($URLPAYBOX)) - { - dol_print_error('',"Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined"); - return -1; - } - if (empty($IBS_SITE)) - { - dol_print_error('',"Paybox setup param PAYBOX_IBS_SITE not defined"); - return -1; - } - if (empty($IBS_RANG)) - { - dol_print_error('',"Paybox setup param PAYBOX_IBS_RANG not defined"); - return -1; - } - - // Definition des parametres vente produit pour paybox - $IBS_CMD=$TAG; - $IBS_TOTAL=$PRICE*100; // En centimes - $IBS_MODE=1; // Mode formulaire - $IBS_PORTEUR=$EMAIL; - $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; // Format des parametres du get de validation en reponse (url a definir sous paybox) - $IBS_TXT=' '; // Use a space - $IBS_BOUTPI=$langs->trans("Wait"); - //$IBS_BOUTPI=''; - $IBS_EFFECTUE=$urlok; - $IBS_ANNULE=$urlko; - $IBS_REFUSE=$urlko; - $IBS_BKGD="#FFFFFF"; - $IBS_WAIT="2000"; - $IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...) - if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA"; - if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP"; - if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA"; - if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU"; - if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD"; - if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE"; - $IBS_OUTPUT='E'; - $PBX_SOURCE='HTML'; - $PBX_TYPEPAIEMENT='CARTE'; - - dol_syslog("Soumission Paybox", LOG_DEBUG); - dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); - dol_syslog("IBS_SITE: $IBS_SITE", LOG_DEBUG); - dol_syslog("IBS_RANG: $IBS_RANG", LOG_DEBUG); - dol_syslog("IBS_TOTAL: $IBS_TOTAL", LOG_DEBUG); - dol_syslog("IBS_DEVISE: $IBS_DEVISE", LOG_DEBUG); - dol_syslog("IBS_CMD: $IBS_CMD", LOG_DEBUG); - dol_syslog("IBS_PORTEUR: $IBS_PORTEUR", LOG_DEBUG); - dol_syslog("IBS_RETOUR: $IBS_RETOUR", LOG_DEBUG); - dol_syslog("IBS_EFFECTUE: $IBS_EFFECTUE", LOG_DEBUG); - dol_syslog("IBS_ANNULE: $IBS_ANNULE", LOG_DEBUG); - dol_syslog("IBS_REFUSE: $IBS_REFUSE", LOG_DEBUG); - dol_syslog("IBS_BKGD: $IBS_BKGD", LOG_DEBUG); - dol_syslog("IBS_WAIT: $IBS_WAIT", LOG_DEBUG); - dol_syslog("IBS_LANG: $IBS_LANG", LOG_DEBUG); - dol_syslog("IBS_OUTPUT: $IBS_OUTPUT", LOG_DEBUG); - dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTIFIANT", LOG_DEBUG); - dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG); - dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG); - - header("Content-type: text/html; charset=".$conf->file->character_set_client); - - print ''."\n"; - print ''."\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print "\n"; - - // Formulaire pour module Paybox - print '
    '."\n"; - - // For Paybox V2 (PBX_xxx) - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - - print ''."\n"; - - - print "\n"; - print ''."\n"; - print "\n"; - print ''."\n"; - print "\n"; - - return; -} - - /** * Show footer of company in HTML pages * diff --git a/htdocs/stripe/checkout.php b/htdocs/public/stripe/checkout.php similarity index 94% rename from htdocs/stripe/checkout.php rename to htdocs/public/stripe/checkout.php index f7f547afae9..4bea80bce6c 100644 --- a/htdocs/stripe/checkout.php +++ b/htdocs/public/stripe/checkout.php @@ -16,15 +16,17 @@ * along with this program. If not, see . */ -require '../main.inc.php'; - -// Load Dolibarr environment -require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'); -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); - define("NOLOGIN",1); define("NOCSRFCHECK",1); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/public/stripe/config.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; + +// Security check +if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + $langs->load("main"); $langs->load("other"); $langs->load("stripe"); @@ -34,19 +36,6 @@ $ref=GETPOST('ref','alpha'); $form = new Form($db); -/** - * Header empty - * - * @return void - */ -function llxHeader() {} -/** - * Footer empty - * - * @return void - */ -function llxFooter() {} - $invoice = null; // Payment on customer invoice @@ -68,8 +57,6 @@ if ($source == 'invoice') { $result=$invoice->fetch_thirdparty($invoice->socid); } - - } $pay = false; @@ -225,7 +212,7 @@ if (GETPOST("action") == 'charge') - + diff --git a/htdocs/stripe/config.php b/htdocs/public/stripe/config.php similarity index 88% rename from htdocs/stripe/config.php rename to htdocs/public/stripe/config.php index 78d394feb53..ac315762b29 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/public/stripe/config.php @@ -22,11 +22,11 @@ * \brief Page to move config in api */ -require '../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/stripe/lib/stripe.lib.php'); -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; //use \includes\stripe as stripe; $stripe = array( diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php deleted file mode 100644 index 33499fe7098..00000000000 --- a/htdocs/public/stripe/newpayment.php +++ /dev/null @@ -1,977 +0,0 @@ - - * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2009-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 . - * - * For test: https://stripe.com/docs - */ - -/** - * \file htdocs/public/stripe/newpayment.php - * \ingroup stripe - * \brief File to offer a way to make a payment for a particular Dolibarr entity - */ - -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; -// require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripefunctions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -// Security check -if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); - -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("errors"); -$langs->load("paybox"); -$langs->load("paypal"); -$langs->load("stripe"); - -// Input are: -// type ('invoice','order','contractline'), -// id (object id), -// amount (required if id is empty), -// tag (a free text, required if type is empty) -// currency (iso code) - -$suffix=GETPOST("suffix",'alpha'); -$amount=price2num(GETPOST("amount")); -if (! GETPOST("currency",'alpha')) $currency=$conf->currency; -else $currency=GETPOST("currency",'alpha'); - -if (! GETPOST("action")) -{ - if (! GETPOST("amount") && ! GETPOST("source")) - { - dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); - exit; - } - if (is_numeric($amount) && ! GETPOST("tag") && ! GETPOST("source")) - { - dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); - exit; - } - if (GETPOST("source") && ! GETPOST("ref")) - { - dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); - exit; - } -} - -// Define $urlwithroot -//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); -//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - -$urlok=$urlwithroot.'/public/stripe/paymentok.php?'; -$urlko=$urlwithroot.'/public/stripe/paymentko.php?'; - -// Complete urls for post treatment -$SOURCE=GETPOST("source",'alpha'); -$ref=$REF=GETPOST('ref','alpha'); -$TAG=GETPOST("tag",'alpha'); -$FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations -$SECUREKEY=GETPOST("securekey"); // Secure key - -if (! empty($SOURCE)) -{ - $urlok.='source='.urlencode($SOURCE).'&'; - $urlko.='source='.urlencode($SOURCE).'&'; -} -if (! empty($REF)) -{ - $urlok.='ref='.urlencode($REF).'&'; - $urlko.='ref='.urlencode($REF).'&'; -} -if (! empty($TAG)) -{ - $urlok.='tag='.urlencode($TAG).'&'; - $urlko.='tag='.urlencode($TAG).'&'; -} -if (! empty($FULLTAG)) -{ - $urlok.='fulltag='.urlencode($FULLTAG).'&'; - $urlko.='fulltag='.urlencode($FULLTAG).'&'; -} -if (! empty($SECUREKEY)) -{ - $urlok.='securekey='.urlencode($SECUREKEY).'&'; - $urlko.='securekey='.urlencode($SECUREKEY).'&'; -} -if (! empty($entity)) -{ - $urlok.='entity='.urlencode($entity).'&'; - $urlko.='entity='.urlencode($entity).'&'; -} -$urlok=preg_replace('/&$/','',$urlok); // Remove last & -$urlko=preg_replace('/&$/','',$urlko); // Remove last & - -// Check parameters -$PAYPAL_API_OK=""; -if ($urlok) $PAYPAL_API_OK=$urlok; -$PAYPAL_API_KO=""; -if ($urlko) $PAYPAL_API_KO=$urlko; -/* -if (empty($PAYPAL_API_USER)) -{ - dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); - return -1; -} -if (empty($PAYPAL_API_PASSWORD)) -{ - dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); - return -1; -} -if (empty($PAYPAL_API_SIGNATURE)) -{ - dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); - return -1; -} -*/ - -// Check security token -$valid=true; -if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) -{ - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) - { - if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical - else $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - } - else - { - $token = $conf->global->PAYPAL_SECURITY_TOKEN; - } - if ($SECUREKEY != $token) $valid=false; - - if (! $valid) - { - print '
    Bad value for key.
    '; - //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; - exit; - } -} - - - -/* - * Actions - */ - -if (GETPOST("action") == 'dopayment') -{ - $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); - $PAYPAL_PAYMENT_TYPE='Sale'; - - $shipToName=GETPOST("shipToName"); - $shipToStreet=GETPOST("shipToStreet"); - $shipToCity=GETPOST("shipToCity"); - $shipToState=GETPOST("shipToState"); - $shipToCountryCode=GETPOST("shipToCountryCode"); - $shipToZip=GETPOST("shipToZip"); - $shipToStreet2=GETPOST("shipToStreet2"); - $phoneNum=GETPOST("phoneNum"); - $email=GETPOST("email"); - $desc=GETPOST("desc"); - - $mesg=''; - if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); - //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); - //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); - elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); - - //var_dump($_POST); - if (empty($mesg)) - { - dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); - - // Other - $PAYPAL_API_DEVISE="USD"; - //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; - //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; - if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; - - dol_syslog("Submit Paypal form", LOG_DEBUG); - dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); - //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files - dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); - dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); - dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); - dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); - dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); - dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); - dol_syslog("shipToName: $shipToName", LOG_DEBUG); - dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); - dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); - dol_syslog("shipToState: $shipToState", LOG_DEBUG); - dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); - dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); - dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); - dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); - dol_syslog("email: $email", LOG_DEBUG); - dol_syslog("desc: $desc", LOG_DEBUG); - - dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO - //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; - //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; - //$_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE; - - // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); - - exit; - } -} - - - -/* - * View - */ - -llxHeaderStripe($langs->trans("PaymentForm")); - -if (! empty($PAYPAL_API_SANDBOX)) -{ - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning'); -} - -// Common variables -$creditor=$mysoc->name; -$paramcreditor='PAYPAL_CREDITOR_'.$suffix; -if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; -else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; - -print ''."\n"; -print '
    '."\n"; -print '
    '."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''; -print "\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print "\n"; - -print '
    global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."
    global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."'; print ""; print ""; @@ -1018,10 +1010,9 @@ else print ''; print ''; print "\n"; - $var=true; - print ""; + print ""; print '
    ".$langs->trans("VATIsNotUsedDesc")."
    '.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").' 
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."'; print ""; print ""; @@ -1049,7 +1040,7 @@ else print "\n"; - print ""; + print ""; print ''; print ""; - print ""; + print ""; print ""; print ''; print ""; - print ""; + print ""; print ""; @@ -304,6 +306,8 @@ if ($resql) print ""; print ''; From 1c20bbb2871808e3e6ee4d5ecf7874a3721c5f4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Apr 2017 12:07:32 +0200 Subject: [PATCH 100/505] NEW Add index and constraints keys on supplier proposal detail table --- .../install/mysql/migration/5.0.0-6.0.0.sql | 5 ++++ .../tables/llx_supplier_proposaldet.key.sql | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql 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 e73c0df2add..9ff9de4e70d 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 @@ -173,4 +173,9 @@ create table llx_default_values ALTER TABLE llx_default_values ADD UNIQUE INDEX uk_default_values(type, entity, user_id, page, param); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_supplier_proposal (fk_supplier_proposal); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_product (fk_product); + +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid); +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_supplier_proposal FOREIGN KEY (fk_supplier_proposal) REFERENCES llx_supplier_proposal (rowid); diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql new file mode 100644 index 00000000000..e6af3c7e515 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql @@ -0,0 +1,26 @@ +-- =================================================================== +-- Copyright (C) 2009-2011 Regis Houssin +-- Copyright (C) 2012 Cédric Salvador +-- +-- 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 . +-- +-- =================================================================== + + + +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_supplier_proposal (fk_supplier_proposal); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_product (fk_product); + +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid); +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_supplier_proposal FOREIGN KEY (fk_supplier_proposal) REFERENCES llx_supplier_proposal (rowid); From 56e749df9f26a82dc988d9d3228b9f99966f8957 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 26 Apr 2017 16:12:27 +0200 Subject: [PATCH 101/505] FIX: supplier order line were always created with rang = 0 --- htdocs/fourn/class/fournisseur.commande.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 11d755b50a4..03898da3943 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1372,10 +1372,13 @@ class CommandeFournisseur extends CommonOrder $localtax2_type=$localtaxes_type[2]; $subprice = price2num($pu,'MU'); + + $rangmax = $this->line_max(); + $rang = $rangmax + 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " (fk_commande, label, description, date_start, date_end,"; - $sql.= " fk_product, product_type,"; + $sql.= " fk_product, product_type, rang,"; $sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,"; $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit"; $sql.= ")"; @@ -1384,7 +1387,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " ".($date_end?"'".$this->db->idate($date_end)."'":"null").","; if ($fk_product) { $sql.= $fk_product.","; } else { $sql.= "null,"; } - $sql.= "'".$product_type."',"; + $sql.= "'".$product_type."', ".$rang.","; $sql.= "'".$qty."', ".$txtva.", ".$txlocaltax1.", ".$txlocaltax2; $sql.= ", '".$localtax1_type."',"; From c69a1205c001b42ce9acaa7cdf62cc8c0f6caee4 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 26 Apr 2017 19:06:41 +0200 Subject: [PATCH 102/505] Fix download delivery document --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 21344f5eca9..f029a569968 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2148,7 +2148,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } // Wrapping pour les bons de livraison - else if ($modulepart == 'livraison' && !empty($conf->livraison->dir_output)) + else if ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file)) { From 508109d5b1201c925fde31cbf35fab0df65f6c36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 00:21:00 +0200 Subject: [PATCH 103/505] Translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4653a22d814..42c6eedae08 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1527,7 +1527,7 @@ EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint availa ApiSetup=API module setup ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services. ApiProductionMode=Enable production mode (this will activate use of a cache for services management) -ApiExporerIs=You can explore the APIs at url +ApiExporerIs=You can explore and test the APIs at URL OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed ApiKey=Key for API WarningAPIExplorerDisabled=The API explorer has been disabled. API explorer is not required to provide API services. It is a tool for developer to find/test REST APIs. If you need this tool, go into setup of module API REST to activate it. From 95788c96994980b12bf13464795bb9b6fc1e294f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 00:53:13 +0200 Subject: [PATCH 104/505] FIX A non admin user can not download files attached to user. --- htdocs/core/lib/files.lib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d27d6c1cdb1..87a587a7460 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1385,7 +1385,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $sqlprotectagainstexternals=''; $ret=array(); - // find the subdirectory name as the reference + // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' if (empty($refname)) $refname=basename(dirname($original_file)."/"); $relative_original_file = $original_file; @@ -1553,6 +1553,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } + // Wrapping for users + else if ($modulepart == 'user' && !empty($conf->user->dir_output)) + { + $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->lire); + if ($user->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + if ($canreaduser || preg_match('/^specimen/i',$original_file)) + { + $accessallowed=1; + } + $original_file=$conf->user->dir_output.'/'.$original_file; + } + // Wrapping for third parties else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) { From d390acc8886a7f48899e5bf180b1d4f42d9c45c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 02:03:59 +0200 Subject: [PATCH 105/505] FIX A non admin user can not download files attached to user. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 87a587a7460..2faa3ae1a8f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1557,7 +1557,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu else if ($modulepart == 'user' && !empty($conf->user->dir_output)) { $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->lire); - if ($user->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card if ($canreaduser || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; From e97fae0c43f0cbfd0cc53dfdadd5e49ef0913835 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 12:10:08 +0200 Subject: [PATCH 106/505] Fix typo --- htdocs/install/mysql/migration/repair.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 03c1ab07dfd..32696ecf593 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -15,8 +15,8 @@ -- Requests to change character set and collation of a column --- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) CHARACTER SET utf8; --- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; +-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; +-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- You can check with "show full columns from llx_accountingaccount"; From 1a98c4a3ffcc8e7201c45ed3021f40c6ec71eb9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 12:48:13 +0200 Subject: [PATCH 107/505] Fix error management in adding translation key --- htdocs/admin/translation.php | 20 ++++++++++++++++---- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 7d07f7ead94..789e85d167d 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -75,7 +75,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $transkey=''; $transvalue=''; @@ -116,7 +116,11 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) } else { - dol_print_error($db); + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); + } + else dol_print_error($db); $action=''; } } @@ -422,9 +426,17 @@ if ($mode == 'searchkey') print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 845e0a62540..c5830b0b003 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -285,7 +285,7 @@ if ($result) { print ''; print ''; print ''; print ''; @@ -303,7 +303,7 @@ if ($result) { print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpitco, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); print "\n"; $facture_static = new Facture($db); From 4c5e78a2cee5c883c7718e8152fbede3554d1b5d Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Thu, 27 Apr 2017 16:30:57 +0200 Subject: [PATCH 111/505] NEW use pdktk to concat mass pdf because tcpdf generate avoid to split large file into multiple smaller file (all have same size) encounter issue with mailer provider virtual delivery service --- htdocs/core/actions_massactions.inc.php | 141 ++++++++++++++++-------- 1 file changed, 93 insertions(+), 48 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 74badc6daae..58e47a29ec8 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -406,60 +406,105 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $outputlangs->setDefaultLang($newlang); } - // Create empty PDF - $pdf=pdf_getInstance(); - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); + if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { + // Create output dir if not exists + dol_mkdir($diroutputmassaction); + + // Defined name of merged file + $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename=preg_replace('/\s/','_',$filename); + + // Save merged file + if ($filter=='paye:0') + { + if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + if ($year) $filename.='_'.$year; + if ($month) $filename.='_'.$month; + + if (count($files)>0) + { + + $now=dol_now(); + $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; + + $input_files = ''; + foreach($files as $f) { + $input_files.=' '.escapeshellarg($f); + } + + $cmd = 'pdftk '.$input_files.' cat output '.escapeshellarg($file); + exec($cmd); + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $langs->load("exports"); + setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + } + } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); + else { + // Create empty PDF + $pdf=pdf_getInstance(); + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - // Add all others - foreach($files as $file) - { - // Charge un document PDF depuis un fichier. - $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { - $tplidx = $pdf->importPage($i); - $s = $pdf->getTemplatesize($tplidx); - $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); - $pdf->useTemplate($tplidx); - } - } + // Add all others + foreach($files as $file) + { + // Charge un document PDF depuis un fichier. + $pagecount = $pdf->setSourceFile($file); + for ($i = 1; $i <= $pagecount; $i++) + { + $tplidx = $pdf->importPage($i); + $s = $pdf->getTemplatesize($tplidx); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tplidx); + } + } - // Create output dir if not exists - dol_mkdir($diroutputmassaction); + // Create output dir if not exists + dol_mkdir($diroutputmassaction); - // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/','_',$filename); - - // Save merged file - if ($filter=='paye:0') - { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); - } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; - if ($pagecount) - { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; - $pdf->Output($file,'F'); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + // Defined name of merged file + $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename=preg_replace('/\s/','_',$filename); + + // Save merged file + if ($filter=='paye:0') + { + if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + if ($year) $filename.='_'.$year; + if ($month) $filename.='_'.$month; + if ($pagecount) + { + $now=dol_now(); + $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; + $pdf->Output($file,'F'); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + $langs->load("exports"); + setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + } } } From 5e856e692369eaf33c5ffa327b63a70792357397 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 17:16:19 +0200 Subject: [PATCH 112/505] More complete tooltip help to describe available substitution vars --- htdocs/admin/chequereceipts.php | 8 +++++++- htdocs/admin/commande.php | 13 +++++++------ htdocs/admin/contract.php | 11 +++++++++-- htdocs/admin/expedition.php | 10 ++++++++-- htdocs/admin/expensereport.php | 10 ++++++++-- htdocs/admin/facture.php | 13 +++++++------ htdocs/admin/fichinter.php | 11 +++++++++-- htdocs/admin/livraison.php | 8 +++++++- htdocs/admin/payment.php | 2 +- htdocs/admin/propal.php | 15 ++++++++------- htdocs/admin/supplier_invoice.php | 8 +++++++- htdocs/admin/supplier_order.php | 9 ++++++++- htdocs/admin/supplier_proposal.php | 11 +++++++++-- .../facture/admin/facture_cust_extrafields.php | 2 +- .../facture/admin/facturedet_cust_extrafields.php | 2 +- htdocs/fourn/card.php | 1 - htdocs/langs/en_US/companies.lang | 8 ++++---- htdocs/societe/agenda.php | 8 +------- htdocs/theme/eldy/style.css.php | 4 ++++ htdocs/theme/md/style.css.php | 3 +++ 20 files changed, 109 insertions(+), 48 deletions(-) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 3b205f49cd2..fd1da0c328b 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -257,8 +257,14 @@ $var=true; $var=! $var; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + print '
    \n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''; print ''; print ''; print ''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''."\n"; //Use draft Watermark print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index ef8b10c411f..d31b788a1ab 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -502,8 +502,14 @@ print ""; print "\n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + print '\n"; print '\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index eda3c6bd6ae..dad17585e2e 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -505,9 +505,15 @@ print ''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''."\n"; //Use draft Watermark print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e7f74f85e5e..d89c9711e3f 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -733,12 +733,18 @@ print '\n"; print ''; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''; print ''; print ''; print ''; print '\n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''; print ''; print ''; print ''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''; print ''; print ''; print '\n"; print ''; */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + print ''; print ''; print ''; print ''; print ''; print "\n"; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + print ''; print ''; print "\n"; $var=false; + //if ($conf->global->MAIN_FEATURES_LEVEL > 0) //{ print '\n"; print "\n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + $var=! $var; print ''; print ''; print ''; print ''; print '"; $colspan=count($fieldlist)+2; - if ($id == 4) $colspan++; - - if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * - { - print ''; - } - print ''; // Keep   to have a line with enough height } + print '
    ".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."'; print ""; print ""; @@ -1069,10 +1060,9 @@ else print ''; print ''; print "\n"; - $var=true; - print ""; + print ""; print ''; // Products - print ''; + print ''; print ''; // Services - print ''; + print ''; print ''; + print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index b0c81ec18af..f7e71555943 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -450,7 +450,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; if ($num) { // There is several pages @@ -499,11 +498,10 @@ if ($id) // Lines with values while ($i < $num) { - $var = ! $var; $obj = $db->fetch_object($resql); //print_r($obj); - print ''; + print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { print ''; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index d9595cd7fb0..af104fd4bfe 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -120,8 +120,7 @@ foreach($workflowcodes as $key => $params) $oldfamily = $family; } - $var = !$var; - print "\n"; + print "\n"; print "'; - $choice .= ''; $choice .= ''; - $choice .= ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print '
    '.$langs->transcountry("LocalTax2Management",$mysoc->country_code).''.$langs->trans("Description").' 
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."'; print ""; print ""; @@ -1101,7 +1091,7 @@ else print "\n"; - print ""; + print ""; print '\n"; foreach ($list as $key) { - - print ''; + print ''; // Param $libelle = $langs->trans($key); diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index 161b1aac45d..74525a6855b 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -105,7 +105,7 @@ foreach ($eventstolog as $key => $arr) print ''."\n"; } } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 6c73afcf8f5..3695a593ece 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2017 Philippe Grand * * 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 @@ -291,7 +291,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -410,7 +409,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/fichinter/doc/"); @@ -532,9 +530,7 @@ print ''; print ''; print "\n"; print "\n"; -$var=true; -$var=! $var; print ''; print ''; print ''; @@ -583,11 +579,10 @@ print '\n"; // Use services duration -$var = !$var; print ''; print ''; print ''; -print ''; +print ''; print ''; From 113d4d1665dd76ab40d0aed3870af2c4d853eab8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Apr 2017 10:29:13 +0200 Subject: [PATCH 095/505] FIX spaces not allowed into vat code --- htdocs/admin/dict.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 046a1cb9b27..3427382ea9f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -680,7 +680,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) 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 - + if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code + { + $_POST["code"]=preg_replace('/\s/','',$_POST["code"]); + } + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) { From e2dbcb2b5a68083711a373f2eaee78513eb20fcb Mon Sep 17 00:00:00 2001 From: philippe grand Date: Tue, 25 Apr 2017 11:59:18 +0200 Subject: [PATCH 096/505] Update code using new css class --- htdocs/admin/loan.php | 4 +--- htdocs/admin/mails_templates.php | 9 ++++----- htdocs/admin/modules.php | 6 ++---- htdocs/admin/oauth.php | 13 ++++--------- htdocs/admin/perms.php | 4 +--- htdocs/admin/salaries.php | 2 +- htdocs/admin/supplier_invoice.php | 5 ++--- htdocs/admin/supplier_order.php | 5 ++--- htdocs/admin/supplier_payment.php | 3 +-- htdocs/admin/syslog.php | 3 +-- htdocs/admin/taxes.php | 10 +++++----- htdocs/admin/websites.php | 4 +--- htdocs/admin/workflow.php | 3 +-- 13 files changed, 26 insertions(+), 45 deletions(-) diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index ee6b9ef74ee..86d963ed54f 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -96,9 +96,7 @@ print "\n"; foreach ($list as $key) { - - - print ''; + print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index f0bf5609adf..a4ec423b42f 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -651,11 +651,10 @@ if ($resql) // Lines with values while ($i < $num) { - $var = ! $var; $obj = $db->fetch_object($resql); //print_r($obj); - print ''; + print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { $tmpaction='edit'; @@ -689,7 +688,7 @@ if ($resql) // Show value for field if ($showfield) { - print ''; - print "\n"; + print "\n"; $url='https://www.dolistore.com'; print ''; print ''; @@ -790,7 +788,7 @@ if ($mode == 'marketplace') print ''; - print "\n"; + print "\n"; $url='https://partners.dolibarr.org'; print ''; print ''; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 34aa49ea237..c1bb5909e15 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -93,7 +93,6 @@ print $langs->trans("ListOfSupportedOauthProviders").'

    '; print '
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."'; print ""; print ""; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index c097b9f39b1..0c42659357a 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2013-2016 Philippe Grand + * Copyright (C) 2013-2017 Philippe Grand * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -119,7 +119,7 @@ print '
    '; print ''; print ''; print "\n"; -print ''; +print ''; print '\n"; -print ''; +print ''; print '\n"; print "
    '.$langs->trans('OptionMode').''.$langs->trans('Description').'
    '.$langs->trans('OptionModeTrue').'
    '.$langs->trans('OptionModeTrue').''.nl2br($langs->trans('OptionModeTrueDesc')); // Write info on way to count VAT //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) @@ -133,7 +133,7 @@ print ''.nl2br($langs->trans('OptionModeTrueDesc')); // // print nl2br($langs->trans('OptionModeTrueInfoExpert')); //} print "
    '.$langs->trans('OptionModeVirtual').'
    '.$langs->trans('OptionModeVirtual').''.nl2br($langs->trans('OptionModeVirtualDesc'))."
    \n"; @@ -149,8 +149,7 @@ print "
    '; $key='MAIN_LOGEVENTS_'.$arr['id']; $value=$conf->global->$key; - print ''; + print ''; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").' 
    '; print ''; print "
    '; print $langs->trans("UseServicesDurationOnFichinter"); print '
    '; // To create an artificial CR for the current tr we are on + print '
    '; // To create an artificial CR for the current tr we are on $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; @@ -781,7 +780,7 @@ if ($resql) // Show value for field if ($showfield) { - print '
    '; // To create an artificial CR for the current tr we are on + print '
    '; // To create an artificial CR for the current tr we are on $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 4eb82e6183c..c47586b2b2a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -428,8 +428,6 @@ $h++; print "
    \n"; -$var=true; - if ($mode == 'common') { @@ -782,7 +780,7 @@ if ($mode == 'marketplace') print '
    '.$langs->trans("DoliStoreDesc").'
    '.$langs->trans("DoliPartnersDesc").'
    '; -$var = true; $i=0; foreach ($list as $key) @@ -116,31 +115,27 @@ foreach ($list as $key) if ($supported) { $redirect_uri=$urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; - $var = !$var; - print ''; + print ''; print ''; print ''; } else { - $var = !$var; - print ''; + print ''; print ''; print ''; print ''; } // Api Id - $var = !$var; - print ''; + print ''; print ''; print ''; // Api Secret - $var = !$var; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index daafab71053..5acbeb2e627 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -140,7 +140,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - $var = True; $oldmod = ""; while ($i < $num) @@ -187,8 +186,7 @@ if ($result) } - print ''; - + print ''; print ''; + print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 2619951e1b5..9e717ee125a 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2017 Philippe Grand * * 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 @@ -361,7 +361,6 @@ foreach ($dirmodels as $reldir) if (is_dir($dir)) { - $var=true; $handle=opendir($dir); @@ -379,7 +378,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db, new FactureFournisseur($db)); - print "\n"; + print "\n"; print "\n"; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index d54f0e367aa..7bca2418df3 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2017 Philippe Grand * * 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 @@ -382,7 +382,6 @@ print ''."\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/"); @@ -403,7 +402,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db, new CommandeFournisseur($db)); - print "\n"; + print "\n"; print "\n"; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 40caa94c8a8..0f6cbff6179 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -367,7 +367,6 @@ foreach ($dirmodels as $reldir) if (is_dir($dir)) { - $var=true; $handle=opendir($dir); @@ -385,7 +384,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db, new PaiementFourn($db)); - print "\n"; + print "\n"; print "\n"; diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71d06ae8e64..40a94bffc71 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -194,7 +194,6 @@ print ''; print ''; print ''; print "\n"; -$var=true; foreach ($syslogModules as $moduleName) { @@ -207,7 +206,7 @@ foreach ($syslogModules as $moduleName) print ''; print ''; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index 788d8604584..dbdce59c3c5 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -136,10 +136,10 @@ else print ''; print ''; print "\n"; - print ''; + print ''; print '\n"; - print ''; + print ''; print '\n"; print "
    '.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; print '
    '.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
    '; print '
    '; print '
    '.img_object('',$picto).' '.$objMod->getName(); print ' '; diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index a04b23ce4fe..52470be4106 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -99,7 +99,7 @@ foreach ($list as $key) { - print '
    "; print (empty($module->name)?$name:$module->name); print "
    "; print (empty($module->name)?$name:$module->name); print "
    "; print (empty($module->name)?$name:$module->name); print "
    '.$langs->trans("Type").''.$langs->trans("Value").'
    '; - print ' '; + print ' '; print $module->getName(); print '
    '.$langs->trans('OptionVatMode').''.$langs->trans('Description').'
    '.$langs->trans('OptionVATDefault').'
    '.$langs->trans('OptionVATDefault').''.nl2br($langs->trans('OptionVatDefaultDesc')); print "
    '.$langs->trans('OptionVATDebitOption').'
    '.$langs->trans('OptionVATDebitOption').''.nl2br($langs->trans('OptionVatDebitOptionDesc'))."
    \n"; @@ -152,7 +152,7 @@ else print '
     '.$langs->trans("Buy").''.$langs->trans("Sell").'
    '.$langs->trans("Product").'
    '.$langs->trans("Product").''; print $langs->trans("OnDelivery"); print ' ('.$langs->trans("SupposedToBeInvoiceDate").')'; @@ -163,7 +163,7 @@ else print '
    '.$langs->trans("Services").'
    '.$langs->trans("Services").''; if ($tax_mode == 0) { @@ -206,7 +206,7 @@ foreach ($list as $key) { - print '
    ".img_object('', $picto).$langs->trans('desc'.$key); if (! empty($params['warning'])) { From 84e774ff32aa0147ef6ac1b8b4c17294b3203933 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Apr 2017 12:57:20 +0200 Subject: [PATCH 097/505] Better translation --- htdocs/install/check.php | 4 ++-- htdocs/install/default.css | 9 +++++---- htdocs/langs/en_US/bookmarks.lang | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index b37837df663..bc7082b8d9d 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -363,7 +363,7 @@ else // Show first install line $choice = '
    '.$langs->trans("FreshInstall").''; $choice .= ''; + $choice .= ''; $choice .= $langs->trans("FreshInstallDesc"); if (empty($dolibarr_main_db_host)) // This means install process was not run { @@ -459,7 +459,7 @@ else $choice .= '
    '.$langs->trans("Upgrade").'
    '.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
    '; + $choice .= ''; $choice .= $langs->trans("UpgradeDesc"); if ($recommended_choice) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 257f2d99af8..9725b06b8bc 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2009-2016 Laurent Destailleur + * Copyright (C) 2009-2017 Laurent Destailleur * * 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 @@ -210,7 +210,9 @@ table.listofchoices, tr.listofchoices, td.listofchoices { tr.listofchoices { height: 42px; } - +.listofchoicesdesc { + color: #999 !important; +} .blinkwait { font-weight: bold; text-decoration:blink !important; @@ -244,9 +246,8 @@ font.warning { div.error { color: #550000; font-weight: bold; - padding: 0.2em 0.2em 0.2em 0.2em; + padding: 0.2em 0.2em 0.2em 0; margin: 0.5em 0 0.5em 0; - border: 1px solid #6C7C8B; } font.error { color: #550000; diff --git a/htdocs/langs/en_US/bookmarks.lang b/htdocs/langs/en_US/bookmarks.lang index d15ed3e1148..9d2003f34d3 100644 --- a/htdocs/langs/en_US/bookmarks.lang +++ b/htdocs/langs/en_US/bookmarks.lang @@ -12,7 +12,7 @@ BookmarkTargetNewWindowShort=New window BookmarkTargetReplaceWindowShort=Current window BookmarkTitle=Bookmark title UrlOrLink=URL -BehaviourOnClick=Behaviour when a URL is clicked +BehaviourOnClick=Behaviour when a bookmark URL is selected CreateBookmark=Create bookmark SetHereATitleForLink=Set a title for the bookmark UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external http URL or a relative Dolibarr URL From 4ab5674ffbbeb8af8ada5cc8c2a5b4b7ccd39bee Mon Sep 17 00:00:00 2001 From: Quentin Vial-Gouteyron Date: Tue, 25 Apr 2017 15:10:46 +0200 Subject: [PATCH 098/505] FIX ajax autocomplete on clone --- htdocs/core/class/html.form.class.php | 13 +++++++++---- htdocs/core/lib/ajax.lib.php | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0b5778a512a..b29f7bc5bf3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -965,18 +965,23 @@ class Form } // mode 1 $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.=''; if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; else if ($hidelabel > 1) { if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("RefOrLabel").'"'; else $placeholder=' title="'.$langs->trans("RefOrLabel").'"'; if ($hidelabel == 2) { - print img_picto($langs->trans("Search"), 'search'); + $out.= img_picto($langs->trans("Search"), 'search'); } } - print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out.= 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { - print img_picto($langs->trans("Search"), 'search'); + $out.= img_picto($langs->trans("Search"), 'search'); } } else diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 0193a33b305..e7d8a7cf538 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -181,10 +181,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt }); } console.log("ajax_autocompleter new value selected, we trigger change on original component so field #search_'.$htmlname.'"); + $("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code. } ,delay: 500 }).data("ui-autocomplete")._renderItem = function( ul, item ) { + return $("
  • ") .data( "ui-autocomplete-item", item ) // jQuery UI > 1.10.0 .append( \'\' + item.label + "" ) From aa4b967e172c1a5d4d306d968648ba1b5cb73dab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Apr 2017 11:46:12 +0200 Subject: [PATCH 099/505] FIX image of rss when link is relative Fix regression after disabling constant init. --- htdocs/admin/external_rss.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f81a5d0fef..30646b749fa 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -206,13 +206,13 @@ print '
  • '.$langs->trans("Example").'
    '.$langs->trans("Title").''.$langs->trans('RSSUrlExample').'
    '.$langs->trans('RSSUrl').'http://news.google.com/news?ned=us&topic=h&output=rss
    http://www.dolibarr.org/rss
    '; @@ -243,10 +243,12 @@ if ($resql) preg_match('/^([0-9]+)/i',$obj->note,$reg); $idrss = $reg[1]; - //print "x".$idrss; + $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; + $keyrsstitle="EXTERNAL_RSS_URLRSS_".$idrss; + //print "x".$idrss; $rssparser=new RssParser($db); - $result = $rssparser->parser(@constant("EXTERNAL_RSS_URLRSS_".$idrss), 5, 300, $conf->externalrss->dir_temp); + $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); $var=true; @@ -269,13 +271,13 @@ if ($resql) print '
    ".$langs->trans("Title")."global->$keyrsstitle . "\">
    ".$langs->trans("URL")."global->$keyrssurl . "\">
    ".$langs->trans("Logo")."'; $imageurl=$rssparser->getImageUrl(); + $linkrss=$rssparser->getLink(); + if (! preg_match('/^http/', $imageurl)) $imageurl=$linkrss.$imageurl; if ($imageurl) print ''; else print $langs->trans("None"); print '
    '.$langcode.''.$key.''; print dol_escape_htmltag($val); print ''; - if ($val != $newlangfileonly->tab_translate[$key]) + if (! empty($newlangfileonly->tab_translate[$key])) { - $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + if ($val != $newlangfileonly->tab_translate[$key]) + { + $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + print $form->textwithpicto('', $htmltext, 1, 'info'); + } + } + else + { + $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key); print $form->textwithpicto('', $htmltext, 1, 'warning'); } /*if (! empty($conf->multicompany->enabled) && !$user->entity) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be60fc5db7c..504470b203d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1075,6 +1075,7 @@ CurrentTranslationString=Current translation string WarningAtLeastKeyOrTranslationRequired=A search criteria is required at least for key or translation string NewTranslationStringToShow=New translation string to show OriginalValueWas=The original translation is overwritten. Original value was:

    %s +TransKeyWithoutOriginalValue=You forced a new translation for the translation key '%s' that does not exists in any language files TotalNumberOfActivatedModules=Total number of activated feature modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index af18693f9d4..72912ca2b1f 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -205,3 +205,4 @@ WarningPaymentDateLowerThanInvoiceDate=Payment date (%s) is earlier than invoice WarningTooManyDataPleaseUseMoreFilters=Too many data (more than %s lines). Please use more filters or set the constant %s to a higher limit. WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while their hourly rate was not defined. A value of 0 %s per hour was used but this may result in wrong valuation of time spent. WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action. +WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language \ No newline at end of file From 9c2ce0202da0799a8994fef2921e0e887cd8cb82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 13:19:07 +0200 Subject: [PATCH 108/505] Translation --- htdocs/langs/en_US/admin.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 504470b203d..bae07caa381 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -298,12 +298,12 @@ LastActivationDate=Latest activation date UpdateServerOffline=Update server offline WithCounter=Manage a counter GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags could be used:
    {000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask.
    {000000+000} same as previous but an offset corresponding to the number to the right of the + sign is applied starting on first %s.
    {000000@x} same as previous but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then sequence {yy}{mm} or {yyyy}{mm} is also required.
    {dd} day (01 to 31).
    {mm} month (01 to 12).
    {yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
    -GenericMaskCodes2={cccc} the client code on n characters
    {cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
    {tttt} The code of third party type on n characters (see dictionary-thirdparty types).
    +GenericMaskCodes2={cccc} the client code on n characters
    {cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
    {tttt} The code of third party type on n characters (see menu Home - Setup - Dictionary - Types of third parties). If you add this tag, the counter will be different for each type of third party.
    GenericMaskCodes3=All other characters in the mask will remain intact.
    Spaces are not allowed.
    -GenericMaskCodes4a=Example on the 99th %s of the third party TheCompany done 2007-01-31:
    +GenericMaskCodes4a=Example on the 99th %s of the third party TheCompany, with date 2007-01-31:
    GenericMaskCodes4b=Example on third party created on 2007-03-01:
    GenericMaskCodes4c=Example on product created on 2007-03-01:
    -GenericMaskCodes5=ABC{yy}{mm}-{000000} will give ABC0701-000099
    {0000+100@1}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX +GenericMaskCodes5=ABC{yy}{mm}-{000000} will give ABC0701-000099
    {0000+100@1}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX
    IN{yy}{mm}-{0000}-{t} will give IN0701-0099-A if the type of company is 'Responsable Inscripto' with code for type that is 'A_RI' GenericNumRefModelDesc=Returns a customizable number according to a defined mask. ServerAvailableOnIPOrPort=Server is available at address %s on port %s ServerNotAvailableOnIPOrPort=Server is not available at address %s on port %s From 1758b836042a3e1776af77a655bb2bc866e99b69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 13:50:13 +0200 Subject: [PATCH 109/505] Clean explanation for accounting module setup. --- htdocs/accountancy/index.php | 9 ++++++--- htdocs/langs/en_US/accountancy.lang | 18 +++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 54772ebf1a4..ff9ca6fa1a3 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -129,15 +129,18 @@ if (! empty($conf->don->enabled)) print "
    \n"; print "
    \n"; }*/ + $step++; -$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").''); print "
    \n"; print "
    \n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
    \n"; +$textlink=''.$langs->transnoentitiesnoconv("MenuBankCash").''; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); print "
    \n"; +print "
    \n"; + print "
    \n"; print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek'); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 42c5c519d2c..57f220f943c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -36,15 +36,15 @@ AccountancyAreaDescActionOnceBis=Next steps should be done to save you time in f AccountancyAreaDescActionFreq=The following actions are usually executed every month, week or day for very large companies... 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 -AccountancyAreaDescBank=STEP %s: Check the binding between bank accounts and accounting account is done. Complete missing bindings. For this, go on the card of each financial account. You can start from page %s. -AccountancyAreaDescVat=STEP %s: Check the binding between vat rates and accounting account is done. Complete missing bindings. You can set accounting accounts to use for each VAT from page %s. -AccountancyAreaDescExpenseReport=STEP %s: Check the binding between type of expense report and accounting account is done. Complete missing bindings. You can set accounting accounts to use for each VAT from page %s. -AccountancyAreaDescSal=STEP %s: Check the binding between salaries payment and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescContrib=STEP %s: Check the binding between special expences (miscellaneous taxes) and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescDonation=STEP %s: Check the binding between donation and accounting account is done. Complete missing bindings. You can set the account dedicated for that from the menu entry %s. -AccountancyAreaDescMisc=STEP %s: Check the default binding between miscellaneous transaction lines and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescProd=STEP %s: Check the binding between products/services and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescLoan=STEP %s: Check the binding between loans payment and accounting account is done. Complete missing bindings. For this you can use the menu entry %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. From 2f23b36ca1b4d31d92822332201c084844dad3d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 14:20:06 +0200 Subject: [PATCH 110/505] Fix typo in var name picto --- htdocs/accountancy/admin/accountmodel.php | 4 ++-- htdocs/accountancy/customer/list.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d2b039a28e0..0b4aa70e548 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -901,8 +901,8 @@ if ($id) if ($id == 4) print '
    '; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; print '
    '; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
    '; -print $langs->trans("FreeLegalTextOnChequeReceipts").' ('.$langs->trans("AddCRIfTooLong").')
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='BANK_CHEQUERECEIPT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 3933f5d00ab..a4680f4d16e 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -565,12 +565,18 @@ print "
     
    '; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -593,11 +599,6 @@ print ""; print ''; print ""; print '
    '; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
    '; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; -$htmltext.='
    '; print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext); print '
    '; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index bc3ea402704..ddd8c6f1c00 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -502,9 +502,15 @@ print ''.$langs->trans("Value").'
    '; -print $langs->trans("FreeLegalTextOnContracts").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -521,7 +527,8 @@ print '
    '; -print $langs->trans("WatermarkOnDraftContractCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext); +print ''; print ''; print '
    ".$langs->trans("Parameter")."
    '; -print $langs->trans("FreeLegalTextOnShippings").' ('.$langs->trans("AddCRIfTooLong").')
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -518,7 +524,7 @@ else print "
    '; -print $langs->trans("WatermarkOnDraft").'
    '; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext).'
    '; print ''; print "
    '; -print $langs->trans("FreeLegalTextOnExpenseReports").' ('.$langs->trans("AddCRIfTooLong").')
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='EXPENSEREPORT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -524,7 +530,7 @@ print '
    '; -print $langs->trans("WatermarkOnDraftOrders").'
    '; +print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htmltext).'
    '; print ''; print '
    '; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -760,11 +766,6 @@ print ''; print ''; print ''; print '
    '; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
    '; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; -$htmltext.='
    '; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext); print '
    '; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 6c73afcf8f5..0b01f56857e 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -534,12 +534,18 @@ print " 
    '; -print $langs->trans("FreeLegalTextOnInterventions").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -562,7 +568,8 @@ print ""; print ''; print ""; print '
    '; -print $langs->trans("WatermarkOnDraftInterventionCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftInterventionCards"), $htmltext).'
    '; +print '
    '; print ''; print ''; print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 281f1934296..143c54ec24d 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -479,12 +479,18 @@ print ' 
    '; -print $langs->trans("FreeLegalTextOnDeliveryReceipts").' ('.$langs->trans("AddCRIfTooLong").')
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index a5166ec69f2..88f2d8cd1c1 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -117,7 +117,7 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'payment', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'payment', $langs->trans("Invoices"), -1, 'invoice'); /* * Numbering module diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 76179fac66c..6a9884e263c 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -570,11 +570,17 @@ print "
    '; -print $langs->trans("FreeLegalTextOnProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -596,12 +602,7 @@ print ""; print ''; print ""; print '
    '; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
    '; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; -$htmltext.='
    '; -print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext); +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
    '; print '
    '; print ''; print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 2619951e1b5..19f0e6fc8e2 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -471,8 +471,14 @@ print ''.$langs->trans("Value").' 
    '; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index d54f0e367aa..a30e7de2654 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -491,6 +491,7 @@ print '
    '.$langs->trans("Value").' 
    '; @@ -536,8 +537,14 @@ else } */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
    '; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
    '; +$htmltext.='
    '; + print '
    '; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 703fbc482e9..345f622a533 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -523,12 +523,18 @@ print '
    '.$langs->trans("Value")." 
    '; -print $langs->trans("FreeLegalTextOnSupplierProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
    '; +print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $langs->trans("AddCRIfTooLong").'

    '.$htmltext).'
    '; $variablename='SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -550,7 +556,8 @@ print ""; print ''; print ""; print '
    '; -print $langs->trans("WatermarkOnDraftSupplierProposal").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
    '; +print '
    '; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index ae545c695c3..c7a43c737de 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -70,7 +70,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index d7fd3367b67..3a5f8c3387f 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -71,7 +71,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index a9ba1ef80aa..4c2716e311a 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -753,7 +753,6 @@ if ($object->id > 0) print ''; - print '
    '; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 38d7a81ab9a..12d1ea188e6 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -77,10 +77,10 @@ VATIsNotUsed=VAT is not used CopyAddressFromSoc=Fill address with third party address ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects PaymentBankAccount=Payment bank account -OverAllProposals=Total proposals -OverAllOrders=Total orders -OverAllInvoices=Total invoices -OverAllSupplierProposals=Total price requests +OverAllProposals=Proposals +OverAllOrders=Orders +OverAllInvoices=Invoices +OverAllSupplierProposals=Price requests ##### Local Taxes ##### LocalTax1IsUsed=Use second tax LocalTax1IsUsedES= RE is used diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index e1dc1c12671..32d13356654 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -83,7 +83,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; @@ -180,12 +180,6 @@ if ($socid > 0) print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - // List of todo actions - //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); - - // List of done actions - //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); - // List of all actions $filters=array(); $filters['search_agenda_label']=$search_agenda_label; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 5c7f1f446ae..f0e615f29ce 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1973,6 +1973,10 @@ div.tabBar { width: auto; background: rgb(); } +div.tabBar div.titre { + padding-top: 10px; +} + div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8cc95628561..d38391504fa 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1992,6 +1992,9 @@ div.tabBar { padding-bottom: 12px; border-bottom: 1px solid #aaa; } +div.tabBar div.titre { + padding-top: 10px; +} div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; From b87eb07b08963056e9da19b20e9599b95b784a42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 17:51:11 +0200 Subject: [PATCH 113/505] Look and feel v6 --- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/index.php | 4 ++-- htdocs/accountancy/admin/journals.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index f7bbbb97969..eaf69f34f1f 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -130,7 +130,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); $var = true; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3ea77a24b43..899aaa1a3d2 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -171,7 +171,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -299,7 +299,7 @@ print '
    transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")); +print '
    '.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
    '; print '
    '; print ''; diff --git a/htdocs/accountancy/admin/journals.php b/htdocs/accountancy/admin/journals.php index 03b51089d9a..677f2a743e5 100644 --- a/htdocs/accountancy/admin/journals.php +++ b/htdocs/accountancy/admin/journals.php @@ -94,7 +94,7 @@ print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'titl $head = admin_accounting_prepare_head(null); -dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron'); +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"; From 853c8a8e07661edce38393dc2e31d9bbd81baf61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 18:05:53 +0200 Subject: [PATCH 114/505] Fix typo --- htdocs/langs/en_US/sendings.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index ef6fe44856b..ac180cb5fe6 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -53,7 +53,7 @@ ShipmentCreationIsDoneFromOrder=For the moment, creation of a new shipment is do ShipmentLine=Shipment line ProductQtyInCustomersOrdersRunning=Product quantity into open customers orders ProductQtyInSuppliersOrdersRunning=Product quantity into open suppliers orders -ProductQtyInShipmentAlreadySent=Product quantity from oped customer order already sent +ProductQtyInShipmentAlreadySent=Product quantity from open customer order already sent ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from open supplier order already received NoProductToShipFoundIntoStock=No product to ship found into warehouse %s. Correct stock or go back to choose another warehouse. WeightVolShort=Weight/Vol. From 18981ab0c9e9c716aa7d31cf9f6eafab3ff2cd23 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 28 Apr 2017 11:39:33 +0200 Subject: [PATCH 115/505] Fix download donation document --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index f029a569968..f1dd6dc6e43 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2199,7 +2199,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } // Wrapping pour les dons - else if ($modulepart == 'donation' && !empty($conf->donation->dir_output)) + else if ($modulepart == 'donation' && !empty($conf->don->dir_output)) { if ($fuser->rights->don->lire || preg_match('/^specimen/i',$original_file)) { From 0ba6433a6166853b4b8a7a4d019c0b9e29a2b68f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 13:10:08 +0200 Subject: [PATCH 116/505] Work on module website --- htdocs/admin/websites.php | 49 +++++-------- .../install/mysql/migration/5.0.0-6.0.0.sql | 3 + htdocs/install/mysql/tables/llx_website.sql | 7 +- .../mysql/tables/llx_website_pages.sql | 6 +- htdocs/langs/en_US/website.lang | 4 +- htdocs/theme/eldy/img/save.png | Bin 0 -> 264 bytes htdocs/theme/md/img/save.png | Bin 0 -> 264 bytes htdocs/websites/class/website.class.php | 47 +++++------- htdocs/websites/class/websitepage.class.php | 13 ++-- htdocs/websites/index.php | 68 +++++++++++++----- 10 files changed, 105 insertions(+), 92 deletions(-) create mode 100644 htdocs/theme/eldy/img/save.png create mode 100644 htdocs/theme/md/img/save.png diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index b0c81ec18af..06e9a7b93a4 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -375,11 +375,11 @@ if ($id) // dans les dictionnaires de donnees $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - $align="left"; + $align=''; if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($valuetoshow != '') { - print '
    '; + 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; @@ -413,14 +413,11 @@ if ($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 ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); } - if ($id == 4) print ''; if ($action != 'edit') { @@ -430,15 +427,9 @@ if ($id) print "
    * '.$langs->trans("LabelUsedByDefault").'.
     
    '; print ''; @@ -453,6 +444,15 @@ if ($id) $var=true; if ($num) { + print '
    '; + + print '
    '; + print ''; + print ''; + print ''; + + print ''; + // There is several pages if ($num > $listlimit) { @@ -503,14 +503,9 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); - print ''; + print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { - print ''; - print ''; - print ''; - print ''; - $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 @@ -548,16 +543,6 @@ if ($id) $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):'').'&id='.$id.'&'; - // Favorite - // Only activated on country dictionary - if ($id == 4) - { - print ''; - } - // Active print '
    '; - if ($iserasable) print ''.$actl[$obj->favorite].''; - else print $langs->trans("AlwaysActive"); - print ''; print ''.$actl[$obj->status].''; @@ -575,15 +560,15 @@ if ($id) } $i++; } + + print '
    '; + + print '
    '; } } else { dol_print_error($db); } - - print '
    '; - - print ''; } print '
    '; 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 9ff9de4e70d..c2edae8b592 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 @@ -137,6 +137,9 @@ ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL; ALTER TABLE llx_cronjob ADD COLUMN processing integer NOT NULL DEFAULT 0; +ALTER TABLE llx_website ADD COLUMN fk_user_create integer; +ALTER TABLE llx_website ADD COLUMN fk_user_modif integer; + create table llx_payment_various ( diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 331e6b085bd..84a9dd47188 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -26,7 +26,8 @@ CREATE TABLE llx_website status integer, fk_default_home integer, virtualhost varchar(255), - date_creation datetime, - date_modification datetime, - tms timestamp + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index 982420dd507..69b6c417528 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -27,6 +27,8 @@ CREATE TABLE llx_website_page keywords varchar(255), content mediumtext, -- text is not enough in size status integer, - date_creation datetime, - tms timestamp + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index fcb09c8d5c1..03069d6f649 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -24,5 +24,5 @@ SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. -PreviewSiteServedByWebServer=Preview %s in a new tab. The %s will be served by an external web server (like Apache, Nginx, IIS). You must instal and setup this server before.
    URL of %s served by external server:
    %s -PreviewSiteServedByDolibarr=Preview %s in a new tab. The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
    The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
    URL of %s served by Dolibarr:
    %s +PreviewSiteServedByWebServer=Preview %s in a new tab.

    The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
    %s
    URL served by external server:
    %s +PreviewSiteServedByDolibarr=Preview %s in a new tab.

    The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
    The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
    URL served by Dolibarr:
    %s

    To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
    %s
    then enter the name of this virtual server and clicking on the other preview button. diff --git a/htdocs/theme/eldy/img/save.png b/htdocs/theme/eldy/img/save.png new file mode 100644 index 0000000000000000000000000000000000000000..eca2d92eccc5665b070d3c04e7241fbc2cbb71d5 GIT binary patch literal 264 zcmV+j0r&oiP)^5To~qfUqA&PMF*F<|kx;Md$&W&;x!#4;TRufSvnyKmY=;&`=O< zD`{EPz!xd^WlTz7A;m7|q5~RSbvmHHRiy(WT*Yq$l(?#OK#Qwh2dre+9fV)gZ4fyZ>#A&pWX|cF@nuJ>{9{^+CL!nen`MaoS0vDoPmT;NZb{N*U=t-36Ko{ O0000^5To~qfUqA&PMF*F<|kx;Md$&W&;x!#4;TRufSvnyKmY=;&`=O< zD`{EPz!xd^WlTz7A;m7|q5~RSbvmHHRiy(WT*Yq$l(?#OK#Qwh2dre+9fV)gZ4fyZ>#A&pWX|cF@nuJ>{9{^+CL!nen`MaoS0vDoPmT;NZb{N*U=t-36Ko{ O0000entity)) { $this->entity = trim($this->entity); } @@ -136,36 +131,30 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = trim($this->status); } - - + if (empty($this->date_creation)) $this->date_creation = dol_now(); // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; $sql.= 'ref,'; $sql.= 'description,'; $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'date_creation,'; - $sql.= 'date_modification'; - + $sql.= 'fk_user_create'; + $sql.= 'date_creation'; $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; $sql .= ' '.(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").','; $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->virtualhost)?'NULL':$this->virtualhost).','; - $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; - $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); - - + $sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'"); $sql .= ')'; $this->db->begin(); @@ -223,8 +212,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { @@ -247,11 +237,10 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_modification = $this->db->jdate($obj->date_modification); $this->tms = $this->db->jdate($obj->tms); - - } $this->db->free($resql); @@ -292,8 +281,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; @@ -331,8 +321,9 @@ class Website extends CommonObject $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_modification = $this->db->jdate($obj->date_modification); $line->tms = $this->db->jdate($obj->tms); $this->records[$line->id] = $line; @@ -377,25 +368,20 @@ class Website extends CommonObject $this->status = trim($this->status); } - - // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; $sql .= ' ref = '.(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").','; $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' virtualhost = '.(($this->virtualhost != '')?"'".$this->db->escape($this->virtualhost)."'":"null").','; + $sql .= ' fk_user_modif = '.(! isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; - $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); - - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -631,6 +617,8 @@ class Website extends CommonObject */ public function initAsSpecimen() { + global $user; + $this->id = 0; $this->entity = 1; @@ -639,8 +627,9 @@ class Website extends CommonObject $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; + $this->fk_user_create = $user->id; + $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); - $this->date_modification = dol_now(); $this->tms = dol_now(); diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 883b6495c53..c80d20fe44b 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -181,7 +181,7 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object + * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one. found * @param string $website_id Web site id * @param string $page Page name * @@ -205,13 +205,16 @@ class WebsitePage extends CommonObject $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + //$sql .= ' WHERE entity IN ('.getEntity('website', 1).')'; // entity is on website level + $sql .= ' WHERE 1 = 1'; if (null !== $website_id) { - $sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\''; - $sql .= ' AND t.pageurl = ' . '\'' . $page . '\''; + $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; + if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } - + $sql .= $this->db->plimit(1); + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b55f81f5b7f..b78a172e01f 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -438,16 +438,34 @@ if ($action == 'updatemeta') // Update page if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')) { - $db->begin(); $object->fetch(0, $website); + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) + { + $object->virtualhost = GETPOST('previewsite', 'alpha'); + $object->update($user); + }*/ + $objectpage->fk_website = $object->id; - $res = $objectpage->fetch($pageid, $object->fk_website); + if ($pageid > 0) + { + $res = $objectpage->fetch($pageid); + } + else + { + $res = $objectpage->fetch($object->fk_default_home); + if (! $res > 0) + { + $res = $objectpage->fetch(0, $object->fk_website); + } + } if ($res > 0) { if ($action == 'updatecontent') { + $db->begin(); + $objectpage->content = GETPOST('PAGE_CONTENT'); // Clean data. We remove all the head section. @@ -632,7 +650,7 @@ if (count($object->records) > 0) // List of websites print '
    '; $out=''; - $out.=''; if (empty($object->records)) $out.=''; // Loop on each sites $i=0; @@ -654,9 +672,9 @@ if (count($object->records) > 0) if ($website) { - $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; + $virtualurl=''; $dataroot=DOL_DATA_ROOT.'/websites/'.$website; - if (! empty($object->virtualhost)) $realurl=$object->virtualhost; + if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } if ($website && $action == 'preview') @@ -680,20 +698,23 @@ if (count($object->records) > 0) if ($action == 'preview') { print '
    '; - print ''; + print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
    '; - $urlext=$realurl; - $urlint=DOL_URL_ROOT.'/public/websites/index.php?website='.$website; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; + //if (! empty($object->virtualhost)) + //{ + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + //} - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlint), 1, 'preview'); + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; } @@ -803,13 +824,22 @@ if (count($object->records) > 0) print $form->textwithpicto('', $htmltext); print '
    '; - $urlext=$realurl.'/'.$pagealias.'.php'; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + if (! empty($object->virtualhost)) + { + $urlext=$virtualurl.'/'.$pagealias.'.php'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } + else + { + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage), 1, 'preview'); + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print ''; From c722286bcb584868d7603f16571299fa327c04a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 13:37:36 +0200 Subject: [PATCH 117/505] Fix regressions --- htdocs/comm/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/langs/en_US/main.lang | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 67ab40f4946..aae1398109d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1098,7 +1098,7 @@ if ($id > 0) else print ''; } - if ($object->client != 0 && $object->client != 2) print ''; + if ($object->client != 0 && $object->client != 2) print ''; else print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6e8c3b6d895..70eea532a79 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2191,7 +2191,7 @@ if ($action == 'create') else { print '
    '; - print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b839e46dc8b..3275ee0f303 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -994,7 +994,7 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 71788071a2d..1a3eea413df 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -823,5 +823,5 @@ SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leaves - +SetMultiCurrencyCode=Set currency BulkActions=Bulk actions \ No newline at end of file From defce63a24456d2f57e14bdfa09faa282ed138aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 14:05:28 +0200 Subject: [PATCH 118/505] Work on management of default values --- htdocs/admin/defaultvalues.php | 9 ++++--- htdocs/core/lib/functions.lib.php | 43 ++++++++++++++++++++++++------- htdocs/langs/en_US/admin.lang | 2 +- htdocs/master.inc.php | 2 +- htdocs/user/class/user.class.php | 4 +-- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 0bc620c41bf..96fef57e7cf 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -187,29 +187,30 @@ $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"],'defaulturl','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'defaultkey','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); 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); + $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"], 'defaultvalue', '', $param, '', $sortfield, $sortorder); +print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,page','',$param,'',$sortfield,$sortorder); print '
    '.$obj->page.''.$obj->param.''; + 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 ''; @@ -280,11 +329,25 @@ if ($result) print ''; print ''; */ - print $obj->value; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + else print ''; print ''; - print ''.img_delete().''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) + { + print ''.img_edit().''; + print '   '; + print ''.img_delete().''; + } + else + { + print ''; + print ''; + print '
    '; + print ''; + print ''; + } print '
    '; + print '
    '; print ''; print ''; print ''; - print '
    '; print ''; print '
    '."\n"; - -// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo) -$width=0; -// Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='PAYBOX_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -else if (! empty($conf->global->PAYBOX_LOGO)) $logosmall=$conf->global->PAYBOX_LOGO; -//print ''."\n"; -// Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) -{ - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode('thumbs/'.$logosmall); -} -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) -{ - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($logo); - $width=96; -} -// Output html code for logo -if ($urllogo) -{ - print ''; - print ''; - print ''."\n"; -} - -// Output introduction text -$text=''; -if (! empty($conf->global->PAYPAL_NEWFORM_TEXT)) -{ - $langs->load("members"); - if (preg_match('/^\((.*)\)$/',$conf->global->PAYPAL_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
    \n"; - else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."
    \n"; - $text=''."\n"; -} -if (empty($text)) -{ - $text.=''."\n"; - $text.=''."\n"; -} -print $text; - -// Output payment summary form -print ''."\n"; - -print '

    '.$text.'

    '.$langs->trans("WelcomeOnPaymentPage").'

    '.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

    '; -print ''; -print ''."\n"; - -$found=false; -$error=0; -$var=false; - -// Free payment -if (! GETPOST("source") && $valid) -{ - $found=true; - $tag=GETPOST("tag"); - $fulltag=$tag; - - // Creditor - $var=!$var; - print ''."\n"; - - // Amount - $var=!$var; - print ''."\n"; - - // Tag - $var=!$var; - print ''."\n"; - - // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum - // as they don't exists (buyer is unknown, tag is free). -} - - -// Payment on customer order -if (GETPOST("source") == 'order' && $valid) -{ - $found=true; - $langs->load("orders"); - - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - - $order=new Commande($db); - $result=$order->fetch('',$ref); - if ($result < 0) - { - $mesg=$order->error; - $error++; - } - else - { - $result=$order->fetch_thirdparty($order->socid); - } - - $amount=$order->total_ttc; - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - - $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; - //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); - if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } - $fulltag=dol_string_unaccent($fulltag); - - // Creditor - $var=!$var; - print ''."\n"; - - // Debitor - $var=!$var; - print ''."\n"; - - // Amount - $var=!$var; - print ''."\n"; - - // Tag - $var=!$var; - print ''."\n"; - - // Shipping address - $shipToName=$order->thirdparty->name; - $shipToStreet=$order->thirdparty->address; - $shipToCity=$order->thirdparty->town; - $shipToState=$order->thirdparty->state_code; - $shipToCountryCode=$order->thirdparty->country_code; - $shipToZip=$order->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$order->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - print 'ref.'">'."\n"; -} - - -// Payment on customer invoice -if (GETPOST("source") == 'invoice' && $valid) -{ - $found=true; - $langs->load("bills"); - - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - - $invoice=new Facture($db); - $result=$invoice->fetch('',$ref); - if ($result < 0) - { - $mesg=$invoice->error; - $error++; - } - else - { - $result=$invoice->fetch_thirdparty($invoice->socid); - } - - $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - - $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; - //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); - if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } - $fulltag=dol_string_unaccent($fulltag); - - // Creditor - $var=!$var; - print ''."\n"; - - // Debitor - $var=!$var; - print ''."\n"; - - // Amount - $var=!$var; - print ''."\n"; - - // Tag - $var=!$var; - print ''."\n"; - - // Shipping address - $shipToName=$invoice->thirdparty->name; - $shipToStreet=$invoice->thirdparty->address; - $shipToCity=$invoice->thirdparty->town; - $shipToState=$invoice->thirdparty->state_code; - $shipToCountryCode=$invoice->thirdparty->country_code; - $shipToZip=$invoice->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$invoice->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - print 'ref.'">'."\n"; -} - -// Payment on contract line -if (GETPOST("source") == 'contractline' && $valid) -{ - $found=true; - $langs->load("contracts"); - - require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - - $contractline=new ContratLigne($db); - $result=$contractline->fetch('',$ref); - if ($result < 0) - { - $mesg=$contractline->error; - $error++; - } - else - { - if ($contractline->fk_contrat > 0) - { - $contract=new Contrat($db); - $result=$contract->fetch($contractline->fk_contrat); - if ($result > 0) - { - $result=$contract->fetch_thirdparty($contract->socid); - } - else - { - $mesg=$contract->error; - $error++; - } - } - else - { - $mesg='ErrorRecordNotFound'; - $error++; - } - } - - $amount=$contractline->total_ttc; - if ($contractline->fk_product) - { - $product=new Product($db); - $result=$product->fetch($contractline->fk_product); - - // We define price for product (TODO Put this in a method in product class) - if (! empty($conf->global->PRODUIT_MULTIPRICES)) - { - $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; - $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; - $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; - } - else - { - $pu_ht = $product->price; - $pu_ttc = $product->price_ttc; - $price_base_type = $product->price_base_type; - } - - $amount=$pu_ttc; - if (empty($amount)) - { - dol_print_error('','ErrorNoPriceDefinedForThisProduct'); - exit; - } - } - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - - $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); - //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); - if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } - $fulltag=dol_string_unaccent($fulltag); - - $qty=1; - if (GETPOST('qty')) $qty=GETPOST('qty'); - - // Creditor - $var=!$var; - print ''."\n"; - - // Debitor - $var=!$var; - print ''."\n"; - - // Quantity - $var=!$var; - $label=$langs->trans("Quantity"); - $qty=1; - $duration=''; - if ($contractline->fk_product) - { - if ($product->isService() && $product->duration_value > 0) - { - $label=$langs->trans("Duration"); - - // TODO Put this in a global method - if ($product->duration_value > 1) - { - $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears")); - } - else - { - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear")); - } - $duration=$product->duration_value.' '.$dur[$product->duration_unit]; - } - } - print ''; - print ''."\n"; - - // Amount - $var=!$var; - print ''."\n"; - - // Tag - $var=!$var; - print ''."\n"; - - // Shipping address - $shipToName=$contract->thirdparty->name; - $shipToStreet=$contract->thirdparty->address; - $shipToCity=$contract->thirdparty->town; - $shipToState=$contract->thirdparty->state_code; - $shipToCountryCode=$contract->thirdparty->country_code; - $shipToZip=$contract->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$contract->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - print 'ref.'">'."\n"; -} - -// Payment on member subscription -if (GETPOST("source") == 'membersubscription' && $valid) -{ - $found=true; - $langs->load("members"); - - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; - - $member=new Adherent($db); - $result=$member->fetch('',$ref); - if ($result < 0) - { - $mesg=$member->error; - $error++; - } - else - { - $subscription=new Subscription($db); - } - - $amount=$subscription->total_ttc; - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - - $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); - if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } - $fulltag=dol_string_unaccent($fulltag); - - // Creditor - $var=!$var; - print ''."\n"; - - // Debitor - $var=!$var; - print ''."\n"; - - if ($member->last_subscription_date || $member->last_subscription_amount) - { - // Last subscription date - $var=!$var; - print ''."\n"; - - // Last subscription amount - $var=!$var; - print ''."\n"; - - if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; - } - - // Amount - $var=!$var; - print ''."\n"; - - // Tag - $var=!$var; - print ''."\n"; - - // Shipping address - $shipToName=$member->getFullName($langs); - $shipToStreet=$member->address; - $shipToCity=$member->town; - $shipToState=$member->state_code; - $shipToCountryCode=$member->country_code; - $shipToZip=$member->zip; - $shipToStreet2=''; - $phoneNum=$member->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - print ''."\n"; -} - - - - -if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); - -if ($mesg) print ''."\n"; - -print '
    '.$langs->trans("ThisIsInformationOnPayment").' :
    '.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
    '.$langs->trans("Amount"); - if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; - print ''; - if (empty($amount) || ! is_numeric($amount)) - { - print ''; - print ''; - } - else { - print ''.price($amount).''; - print ''; - print ''; - } - // Currency - print ' '.$langs->trans("Currency".$currency).''; - print ''; - print '
    '.$langs->trans("PaymentCode"); - print ''.$fulltag.''; - print ''; - print ''; - print '
    '.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
    '.$langs->trans("ThirdParty"); - print ''.$order->thirdparty->name.''; - - // Object - $var=!$var; - $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; - print '
    '.$langs->trans("Designation"); - print ''.$text; - print ''; - print ''; - print '
    '.$langs->trans("Amount"); - if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; - print ''; - if (empty($amount) || ! is_numeric($amount)) - { - print ''; - print ''; - } - else { - print ''.price($amount).''; - print ''; - print ''; - } - // Currency - print ' '.$langs->trans("Currency".$currency).''; - print ''; - print '
    '.$langs->trans("PaymentCode"); - print ''.$fulltag.''; - print ''; - print ''; - print '
    '.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
    '.$langs->trans("ThirdParty"); - print ''.$invoice->thirdparty->name.''; - - // Object - $var=!$var; - $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; - print '
    '.$langs->trans("Designation"); - print ''.$text; - print ''; - print ''; - print '
    '.$langs->trans("Amount"); - if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; - print ''; - if (empty($amount) || ! is_numeric($amount)) - { - print ''; - print ''; - } - else { - print ''.price($amount).''; - print ''; - print ''; - } - // Currency - print ' '.$langs->trans("Currency".$currency).''; - print ''; - print '
    '.$langs->trans("PaymentCode"); - print ''.$fulltag.''; - print ''; - print ''; - print '
    '.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
    '.$langs->trans("ThirdParty"); - print ''.$contract->thirdparty->name.''; - - // Object - $var=!$var; - $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).''; - if ($contractline->fk_product) - { - $text.='
    '.$product->ref.($product->label?' - '.$product->label:''); - } - if ($contractline->description) $text.='
    '.dol_htmlentitiesbr($contractline->description); - //if ($contractline->date_fin_validite) { - // $text.='
    '.$langs->trans("DateEndPlanned").': '; - // $text.=dol_print_date($contractline->date_fin_validite); - //} - if ($contractline->date_fin_validite) - { - $text.='
    '.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); - } - - print '
    '.$langs->trans("Designation"); - print ''.$text; - print ''; - print ''; - print '
    '.$label.''.($duration?$duration:$qty).''; - print ''; - print '
    '.$langs->trans("Amount"); - if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; - print ''; - if (empty($amount) || ! is_numeric($amount)) - { - print ''; - print ''; - } - else { - print ''.price($amount).''; - print ''; - print ''; - } - // Currency - print ' '.$langs->trans("Currency".$currency).''; - print ''; - print '
    '.$langs->trans("PaymentCode"); - print ''.$fulltag.''; - print ''; - print ''; - print '
    '.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
    '.$langs->trans("Member"); - print ''; - if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe; - else print $member->getFullName($langs); - print ''; - - // Object - $var=!$var; - $text=''.$langs->trans("PaymentSubscription").''; - print '
    '.$langs->trans("Designation"); - print ''.$text; - print ''; - print ''; - print '
    '.$langs->trans("LastSubscriptionDate"); - print ''.dol_print_date($member->last_subscription_date,'day'); - print '
    '.$langs->trans("LastSubscriptionAmount"); - print ''.price($member->last_subscription_amount); - print '
    '.$langs->trans("Amount"); - if (empty($amount)) - { - print ' ('.$langs->trans("ToComplete"); - if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").''; - print ')'; - } - print ''; - if (empty($amount) || ! is_numeric($amount)) - { - $valtoshow=GETPOST("newamount",'int'); - if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); - print ''; - print ''; - } - else { - $valtoshow=$amount; - if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); - print ''.price($valtoshow).''; - print ''; - print ''; - } - // Currency - print ' '.$langs->trans("Currency".$currency).''; - print ''; - print '
    '.$langs->trans("PaymentCode"); - print ''.$fulltag.''; - print ''; - print ''; - print '

    '.$mesg.'
    '."\n"; -print "\n"; - -if ($found && ! $error) // We are in a management option and no error -{ - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; - - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') - { - print '
    '; - } - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'stripeonly') - { - print '
    '; - } -} -else -{ - dol_print_error_email('ERRORNEWPAYMENTPAYPAL'); -} - -print '
    '."\n"; -print ''."\n"; -print ''."\n"; -print '
    '; - - -html_print_stripe_footer($mysoc,$langs); - -llxFooterStripe(); - -$db->close(); diff --git a/htdocs/public/stripe/paymentko.php b/htdocs/public/stripe/paymentko.php deleted file mode 100644 index 09de4525b39..00000000000 --- a/htdocs/public/stripe/paymentko.php +++ /dev/null @@ -1,115 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * - * 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/public/paybox/paymentko.php - * \ingroup paybox - * \brief File to show page after a failed payment - * \author Laurent Destailleur - */ - -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// Security check -if (empty($conf->paybox->enabled)) accessforbidden('',0,0,1); - -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("paybox"); -$langs->load("paypal"); - - - - -/* - * Actions - */ - - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayBox payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); - - -// Send an email -if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) -{ - $sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentFailed"); - $content=$langs->transnoentitiesnoconv("NewPayboxPaymentFailed")."\n".$fulltag; - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); - } -} - - -llxHeaderPayBox($langs->trans("PaymentForm")); - - -// Show message -print ''."\n"; -print '
    '."\n"; - -print $langs->trans("YourPaymentHasNotBeenRecorded")."

    \n"; - -if (! empty($conf->global->PAYBOX_MESSAGE_KO)) print $conf->global->PAYBOX_MESSAGE_KO; - -print "\n
    \n"; - - -html_print_paybox_footer($mysoc,$langs); - - -llxFooterPayBox(); - -$db->close(); diff --git a/htdocs/public/stripe/paymentok.php b/htdocs/public/stripe/paymentok.php deleted file mode 100644 index 9c3030a86ba..00000000000 --- a/htdocs/public/stripe/paymentok.php +++ /dev/null @@ -1,172 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * - * 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/public/paybox/paymentok.php - * \ingroup paybox - * \brief File to show page after a successful payment - * \author Laurent Destailleur - */ - -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// Security check -if (empty($conf->paybox->enabled)) accessforbidden('',0,0,1); - -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("paybox"); -$langs->load("paypal"); - -/*$source=GETPOST('source'); -$ref=GETPOST('ref'); -$PAYBOXTOKEN=GETPOST('TOKEN'); -if (empty($PAYBOXTOKEN)) $PAYBOXTOKEN=GETPOST('token'); -$PAYBOXPAYERID=GETPOST('PAYERID'); -if (empty($PAYBOXPAYERID)) $PAYBOXPAYERID=GETPOST('PayerID'); -*/ -$PAYBOXFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYBOXFULLTAG)) $PAYBOXFULLTAG=GETPOST('fulltag'); - - -/* - * Actions - */ - - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayBox payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); - -llxHeaderPayBox($langs->trans("PaymentForm")); - - -// Show message -print ''."\n"; -print '
    '."\n"; - -// Get on url call -/* -$token = $PAYBOXTOKEN; -*/ -$fulltag = $PAYBOXFULLTAG; -/*$payerID = $PAYBOXPAYERID; -// Set by newpayment.php -$paymentType = $_SESSION['PaymentType']; -$currencyCodeType = $_SESSION['currencyCodeType']; -$FinalPaymentAmt = $_SESSION["Payment_Amount"]; -// From env -$ipaddress = $_SESSION['ipaddress']; - -dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); -*/ - - -print $langs->trans("YourPaymentHasBeenRecorded")."

    \n"; - -if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK; - -// Appel des triggers -include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; -$interface=new Interfaces($db); -$result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf); -if ($result < 0) { $error++; $errors=$interface->errors; } -// Fin appel triggers - - -// Send an email -if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) -{ - $sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentReceived"); - $tmptag=dolExplodeIntoArray($fulltag,'.','='); - $content=""; - if (! empty($tmptag['MEM'])) - { - $langs->load("members"); - $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
    \n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
    \n"; - $content.=$langs->trans("Link").': '.$url.''."
    \n"; - } - else - { - $content.=$langs->transnoentitiesnoconv("NewPayboxPaymentReceived")."
    \n"; - } - $content.="
    \n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
    \n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
    \n"; - $content.="tag=".$fulltag."
    \n"; - - $ishtml=dol_textishtml($content); // May contain urls - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - - // Send an email - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); - } -} - - - -print "\n
    \n"; - -html_print_paybox_footer($mysoc,$langs); - - -llxFooterPayBox(); - -$db->close(); diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 719c623e146..4da06e61de8 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -23,7 +23,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -31,6 +31,8 @@ $servicename='Stripe'; $langs->load("admin"); $langs->load("other"); +$langs->load("paypal"); +$langs->load("paybox"); $langs->load("stripe"); if (!$user->admin) @@ -43,7 +45,7 @@ if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, "STRIPE_API_SANDBOX",GETPOST('STRIPE_API_SANDBOX','alpha'),'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "STRIPE_TEST",GETPOST('STRIPE_TEST','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; @@ -118,8 +120,8 @@ print "
    '; -print $langs->trans("STRIPE_API_SANDBOX").''; -print $form->selectyesno("STRIPE_API_SANDBOX",$conf->global->STRIPE_API_SANDBOX,1); +print $langs->trans("STRIPE_TEST").''; +print $form->selectyesno("STRIPE_TEST",$conf->global->STRIPE_TEST,1); print '
    '; + +print '
    '; + +print ''; print ''; print ''; print ''; @@ -173,14 +179,14 @@ print ''; $var=!$var; print ''; $var=!$var; print ''; @@ -194,6 +200,7 @@ print ''; print '

    '; +/* print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
    '; print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
    '; print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount=9.99&tag=your_free_tag'."
    \n"; @@ -220,6 +227,7 @@ if (! empty($conf->adherent->enabled)) print "
    "; print info_admin($langs->trans("YouCanAddTagOnUrl")); +*/ llxFooter(); From d73374cc5b2865ee9eabfff0a29dc00b3a20f7c8 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Apr 2017 07:34:30 +0200 Subject: [PATCH 124/505] Uniformize link to stripe.lib --- htdocs/public/stripe/checkout.php | 2 +- htdocs/public/stripe/config.php | 2 +- htdocs/stripe/admin/stripe.php | 2 +- htdocs/stripe/lib/index.html | 0 htdocs/{core => stripe}/lib/stripe.lib.php | 60 ++++++++++------------ 5 files changed, 31 insertions(+), 35 deletions(-) create mode 100644 htdocs/stripe/lib/index.html rename htdocs/{core => stripe}/lib/stripe.lib.php (99%) diff --git a/htdocs/public/stripe/checkout.php b/htdocs/public/stripe/checkout.php index 4bea80bce6c..3f0b6f84016 100644 --- a/htdocs/public/stripe/checkout.php +++ b/htdocs/public/stripe/checkout.php @@ -20,7 +20,7 @@ define("NOLOGIN",1); define("NOCSRFCHECK",1); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/public/stripe/config.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; diff --git a/htdocs/public/stripe/config.php b/htdocs/public/stripe/config.php index ac315762b29..b94617b4c69 100644 --- a/htdocs/public/stripe/config.php +++ b/htdocs/public/stripe/config.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; //use \includes\stripe as stripe; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 4da06e61de8..1882d1065b0 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -23,7 +23,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/stripe/lib/index.html b/htdocs/stripe/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/core/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php similarity index 99% rename from htdocs/core/lib/stripe.lib.php rename to htdocs/stripe/lib/stripe.lib.php index 175df3554ce..0ab73437e17 100644 --- a/htdocs/core/lib/stripe.lib.php +++ b/htdocs/stripe/lib/stripe.lib.php @@ -21,7 +21,35 @@ * \brief Library for common stripe functions */ +/** + * Define head array for tabs of stripe tools setup pages + * + * @return Array of head + */ +function stripeadmin_prepare_head() +{ + global $langs, $conf; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/stripe/admin/stripe.php"; + $head[$h][1] = $langs->trans("Stripe"); + $head[$h][2] = 'stripeaccount'; + $h++; + + $object=new stdClass(); + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin','remove'); + + return $head; +} /** * Show header @@ -70,38 +98,6 @@ function llxFooterStripe() print "\n"; } -/** - * Define head array for tabs of stripe tools setup pages - * - * @return Array of head - */ -function stripeadmin_prepare_head() -{ - global $langs, $conf; - - $h = 0; - $head = array(); - - $head[$h][0] = DOL_URL_ROOT."/stripe/admin/stripe.php"; - $head[$h][1] = $langs->trans("Stripe"); - $head[$h][2] = 'stripeaccount'; - $h++; - - $object=new stdClass(); - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin'); - - complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin','remove'); - - return $head; -} - - - /** * Return string with full Url * From ce62736e6b46e9442d4aa01133339895c9630474 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Apr 2017 07:57:36 +0200 Subject: [PATCH 125/505] Correct link and renamed checkout by newpayment --- .../stripe/{checkout.php => newpayment.php} | 14 ++++-- htdocs/stripe/lib/stripe.lib.php | 50 +------------------ 2 files changed, 11 insertions(+), 53 deletions(-) rename htdocs/public/stripe/{checkout.php => newpayment.php} (94%) diff --git a/htdocs/public/stripe/checkout.php b/htdocs/public/stripe/newpayment.php similarity index 94% rename from htdocs/public/stripe/checkout.php rename to htdocs/public/stripe/newpayment.php index 3f0b6f84016..71f581000b2 100644 --- a/htdocs/public/stripe/checkout.php +++ b/htdocs/public/stripe/newpayment.php @@ -16,6 +16,12 @@ * along with this program. If not, see . */ +/** +* \file htdocs/public/stripe/newpayment.php +* \ingroup Stripe +* \brief Page to do payment with Stripe +*/ + define("NOLOGIN",1); define("NOCSRFCHECK",1); @@ -25,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/public/stripe/config.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; // Security check -if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); +if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); $langs->load("main"); $langs->load("other"); @@ -67,13 +73,13 @@ if (GETPOST("action") == 'charge') $token = GETPOST("stripeToken"); $email = GETPOST("stripeEmail"); - $customer = \Stripe\Customer::create(array( + $customer = \stripe\Customer::create(array( 'email' => $email, 'card' => $token )); $ttc = round($ttc, 2); - $charge = \Stripe\Charge::create(array( + $charge = \stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => $ttc, 'currency' => $conf->currency, @@ -122,7 +128,7 @@ if (GETPOST("action") == 'charge') diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php index 0ab73437e17..c454296a304 100644 --- a/htdocs/stripe/lib/stripe.lib.php +++ b/htdocs/stripe/lib/stripe.lib.php @@ -112,6 +112,7 @@ function showStripePaymentUrl($type,$ref) $langs->load("paypal"); $langs->load("paybox"); $langs->load("stripe"); + $servicename='Stripe'; $out='

    '; $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
    '; @@ -139,11 +140,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($type == 'free') { $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - } } if ($type == 'order') { @@ -151,17 +147,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='order_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'invoice') { @@ -169,17 +154,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='invoice_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'contractline') { @@ -187,17 +161,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='contractline_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'membersubscription') { @@ -205,17 +168,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='member_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } // For multicompany From faddcb28ac9fafb54ad8124f0eef77f2561926f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Apr 2017 14:53:29 +0200 Subject: [PATCH 126/505] FIX serious bugs in accounting (error management, transactions, bad values set) --- .../accountancy/class/bookkeeping.class.php | 15 +- htdocs/accountancy/customer/lines.php | 16 +- htdocs/accountancy/customer/list.php | 9 +- htdocs/accountancy/journal/bankjournal.php | 291 +++++++++--------- .../journal/expensereportsjournal.php | 250 ++++++++------- .../accountancy/journal/purchasesjournal.php | 259 +++++++++------- htdocs/accountancy/journal/sellsjournal.php | 240 +++++++++------ htdocs/accountancy/supplier/lines.php | 9 +- htdocs/accountancy/supplier/list.php | 9 +- htdocs/core/lib/accounting.lib.php | 92 ++++++ htdocs/core/lib/functions.lib.php | 2 +- 11 files changed, 731 insertions(+), 461 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 754dd262369..8f31b40bc54 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -169,7 +169,15 @@ class BookKeeping extends CommonObject if (empty($this->numero_compte) || $this->numero_compte == '-1') { $langs->load("errors"); - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet); + if (in_array($this->doc_type, array('bank', 'expense_report'))) + { + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); + } + else + { + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + } + return -1; } @@ -178,11 +186,12 @@ class BookKeeping extends CommonObject $this->piece_num = 0; - // first check if line not yet in bookkeeping + // First check if line not yet already in bookkeeping $sql = "SELECT count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; - $sql .= " AND fk_docdet = " . $this->fk_docdet; + $sql .= " AND fk_doc = " . $this->fk_doc; + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index a015fa05929..428e490aff7 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -43,6 +43,7 @@ $langs->load("productbatch"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); // Search Getpost +$search_lineid = GETPOST('search_lineid', 'int'); $search_ref = GETPOST('search_ref', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -86,6 +87,7 @@ $formventilation = new FormVentilation($db); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -151,7 +153,7 @@ print ' -status != 1) { ?> +status != 1) { ?> trans('AddInventoryProduct'); ?> :
    - + - + - + @@ -90,7 +90,7 @@ - +
    '.$langs->trans("UsageParameter").''.$langs->trans("Value").'
    '; print $langs->trans("MessageOK").''; -$doleditor=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
    '; print $langs->trans("MessageKO").''; -$doleditor=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
    - Invoice #: ref; ?>
    + trans("Invoice") . ' : ' . $invoice->ref; ?>
    trans('Date') . ' : ' . dol_print_date($invoice->date, 'day'); ?>
    trans('DateMaxPayment') . ' : ' . dol_print_date($invoice->date_validation, 'day'); ?>
    - 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 138/505] 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 139/505] 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 140/505] 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 '
    '; $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 141/505] 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 142/505] 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 d658a833c98fad5e2b21ca4c5f3ad44e51ad4717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 1 May 2017 12:05:52 +0200 Subject: [PATCH 150/505] FIX #6677 Expired contracts dashboard box does not show the name of the thirdparty Close #6677 --- htdocs/core/boxes/box_services_expired.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index f2bc86cdac5..52ccb694dd3 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -104,7 +104,7 @@ class box_services_expired extends ModeleBoxes 'logo' => 'company', 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => 'class="tdoverflow maxwidth100onsmartphone" align="left"', + $this->info_box_contents[$i][3] = array('td' => 'class="tdoverflowmax200 maxwidth100onsmartphone" align="left"', 'text' => $objp->name, 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); From 5af5c23a987f9d0025653da691120c6e8e3516e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 May 2017 12:46:40 +0200 Subject: [PATCH 151/505] 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 143/505] 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 144/505] 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 145/505] 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 146/505] 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 147/505] 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 148/505] 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 149/505] 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 152/505] 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 $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 153/505] 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 154/505] 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 155/505] 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").''; if (! empty($conf->accounting->enabled)) { - print length_accountg($object->account_number).'
    '; - 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 156/505] 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 157/505] 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 158/505] 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 159/505] 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 160/505] 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 161/505] 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 162/505] 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 163/505] 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 '
    '.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print ''; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print ''; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print ''; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + 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 '
    '.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP; + print '
    '.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + print empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM; + 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 164/505] 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 165/505] 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 166/505] 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 167/505] 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 168/505] 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 169/505] 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 170/505] 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 171/505] 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 172/505] 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 173/505] 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 174/505] 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 175/505] 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 176/505] 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 177/505] 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 178/505] 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 179/505] 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 180/505] 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 181/505] [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 182/505] 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 183/505] 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 184/505] 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 185/505] 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 186/505] 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 187/505] 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 188/505] 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 b8d63ae6c0c927326cd31e37c0b85f7d73070c1e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 4 May 2017 14:04:30 +0200 Subject: [PATCH 189/505] Better fix --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7f10fca51f8..3687a070dbb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1437,7 +1437,7 @@ class Form { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " ON ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity; + $sql.= " WHERE ug.entity = ".$conf->entity; } else { From ea58fb0b50b947e623abc439cb0fb93c4f8f4c7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 15:52:12 +0200 Subject: [PATCH 190/505] 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 191/505] 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 198/505] 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 199/505] 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 200/505] 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 201/505] [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 202/505] 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 203/505] 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 192/505] 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 193/505] 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 194/505] 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 195/505] 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 196/505] 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 197/505] 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 204/505] =?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 205/505] 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 206/505] 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 207/505] 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 208/505] 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 209/505] 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 210/505] 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 211/505] 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 212/505] 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 213/505] 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 214/505] 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 215/505] 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 216/505] 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 217/505] 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 218/505] 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 d93552c8c5311ba7a4853aa0993105d9322894e7 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 5 May 2017 17:13:29 +0000 Subject: [PATCH 219/505] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/core/class/commoninvoice.class.php | 2 +- .../modules/supplier_payment/doc/pdf_standard.modules.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2e2a26dd9ae..4b6d70b1366 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -95,7 +95,7 @@ abstract class CommonInvoice extends CommonObject * This does not include open direct debit requests. * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int Remain of amount to pay + * @return double Remain of amount to pay */ function getRemainToPay($multicurrency=0) { diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 2b645e4a263..6fbfb4b1bf4 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -520,8 +520,8 @@ class pdf_standard extends ModelePDFSuppliersPayments * Show table for lines * * @param PDF $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) + * @param integer $tab_top Top position of table + * @param integer $tab_height Height of table (rectangle) * @param int $nexY Y (not used) * @param Translate $outputlangs Langs object * @param int $hidetop Hide top bar of array From d53654e64f46ff71aa5f4b87f62557371471b614 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 20:41:44 +0200 Subject: [PATCH 220/505] 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 e28dff19eeca36c6245c7924f3ed321d9822c46f Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 5 May 2017 22:21:46 +0200 Subject: [PATCH 221/505] Fix bug xhen insert new bankline --- htdocs/compta/bank/class/account.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 897fd5de496..97dacf34386 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -471,9 +471,9 @@ class Account extends CommonObject if ($accline->insert() > 0) { - if ($categorie) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_account ("; - $sql .= "fk_account, fk_categorie"; + if ($categorie>0) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql .= "lineid, fk_categ; $sql .= ") VALUES ("; $sql .= " ".$accline->id.", ".$categorie; $sql .= ")"; From 0fbf27895ad891ee9889e3e8a80a172dead1e975 Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 5 May 2017 22:33:34 +0200 Subject: [PATCH 222/505] Add fk_facture_fourn element to fetch lines objects --- htdocs/fourn/class/fournisseur.facture.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1798eb19059..496c4660895 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -640,7 +640,7 @@ class FactureFournisseur extends CommonInvoice function fetch_lines() { $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; - $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; + $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; @@ -649,6 +649,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ' WHERE fk_facture_fourn='.$this->id; $sql.= ' ORDER BY f.rang, f.rowid'; + dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql_rows = $this->db->query($sql); if ($resql_rows) @@ -687,6 +688,7 @@ class FactureFournisseur extends CommonInvoice $line->total_tva = $obj->total_tva; $line->total_localtax1 = $obj->total_localtax1; $line->total_localtax2 = $obj->total_localtax2; + $line->fk_facture_fourn = $obj->fk_facture_fourn; $line->total_ttc = $obj->total_ttc; $line->fk_product = $obj->fk_product; $line->product_type = $obj->product_type; From cea835744c61486f2cadafec2e589fe6578fc628 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 May 2017 23:06:46 +0200 Subject: [PATCH 223/505] 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 224/505] 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 225/505] 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.= ''; - print ''; + print ''; } print '
    '; +$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 '
    '.$langs->trans("AccountancyJournal").'accountancy_journal).'">
    '; + print $formaccountancy2->select_journal($object->accountancy_journal, 'accountancy_journal', 4, 1, '', 1, 1); + print '
    '; @@ -980,8 +984,10 @@ else // Accountancy journal if (! empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountancyJournal").''; - print 'accountancy_journal).'">'; + print ''.$langs->trans("AccountancyJournal").''; + print ''; + print $formaccountancy2->select_journal($object->accountancy_journal, 'accountancy_journal', 4, 1, '', 1, 1); + print ''; } print ''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index cb988a511cd..1a33f0fce60 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -60,37 +60,49 @@ class FormAccounting extends Form { global $conf; - $sql = "SELECT rowid, code, label, nature, entity, active"; - $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND active = 1"; - if (empty($nature)) $sql.= " AND nature = ".$nature; - $sql.= " ORDER BY code"; + $out = ''; - dol_syslog(get_class($this) . "::select_journal", LOG_DEBUG); - $resql = $this->db->query($sql); + $options = array(); + if ($usecache && ! empty($this->options_cache[$usecache])) + { + $options = $this->options_cache[$usecache]; + $selected=$selectid; + } + else + { + $sql = "SELECT rowid, code, label, nature, entity, active"; + $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; + $sql.= " WHERE active = 1"; + $sql.= " AND entity = ".$conf->entity; + //if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; + $sql.= " ORDER BY code"; - if (!$resql) { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::select_journal ".$this->error, LOG_ERR); - return -1; + dol_syslog(get_class($this) . "::select_journal", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_journal ".$this->error, LOG_ERR); + return -1; + } + + $out = ajax_combobox($htmlname, $event); + + while ($obj = $this->db->fetch_object($resql)) + { + $label = $obj->code . ' - ' . $obj->label; + $select_value_out = $obj->rowid; + + $options[$select_value_out] = $label; + } + $this->db->free($resql); + + if ($usecache) + { + $this->options_cache[$usecache] = $options; + } } - $options = array(); - $out = ajax_combobox($htmlname, $event); - - $selected = 0; - while ($obj = $this->db->fetch_object($resql)) - { - $label = $obj->code . ' - ' . $obj->label; - } - $this->db->free($resql); - - if ($usecache) - { - $this->options_cache[$usecache] = $options; - } - $out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; 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 d96210dcbfe..9e4699b2e4b 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 @@ -259,4 +259,11 @@ 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; +ALTER TABLE llx_bank_account CHANGE COLUMN accountancy_journal fk_accountancy_journal integer; +ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); + + + + + diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql index a435de3cd80..348654b56dc 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql @@ -23,6 +23,6 @@ create table llx_accounting_journal 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) + nature smallint DEFAULT 1 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/install/mysql/tables/llx_bank_account.key.sql b/htdocs/install/mysql/tables/llx_bank_account.key.sql index c91762a322e..0a168d63990 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.key.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.key.sql @@ -19,3 +19,5 @@ ALTER TABLE llx_bank_account ADD UNIQUE uk_bank_account_label (label,entity); + +ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql index 7730ab79ef6..6db2857ddae 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.sql @@ -24,39 +24,39 @@ create table llx_bank_account ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - ref varchar(12) NOT NULL, - label varchar(30) NOT NULL, - entity integer DEFAULT 1 NOT NULL, -- multi company id - fk_user_author integer, - fk_user_modif integer, - bank varchar(60), - code_banque varchar(128), - code_guichet varchar(6), - number varchar(255), - cle_rib varchar(5), - bic varchar(11), - iban_prefix varchar(34), -- full iban. 34 according to ISO 13616 - country_iban varchar(2), -- deprecated - cle_iban varchar(2), - domiciliation varchar(255), - state_id integer DEFAULT NULL, - fk_pays integer NOT NULL, - proprio varchar(60), - owner_address varchar(255), - courant smallint DEFAULT 0 NOT NULL, - clos smallint DEFAULT 0 NOT NULL, - rappro smallint DEFAULT 1, - url varchar(128), - account_number varchar(32), -- bank accountancy number - accountancy_journal varchar(16) DEFAULT NULL, -- bank accountancy journal - currency_code varchar(3) NOT NULL, - min_allowed integer DEFAULT 0, - min_desired integer DEFAULT 0, - comment text, -- TODO rename in note_private - note_public text, - model_pdf varchar(255), - import_key varchar(14) + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + tms timestamp, + ref varchar(12) NOT NULL, + label varchar(30) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_user_author integer, + fk_user_modif integer, + bank varchar(60), + code_banque varchar(128), + code_guichet varchar(6), + number varchar(255), + cle_rib varchar(5), + bic varchar(11), + iban_prefix varchar(34), -- full iban. 34 according to ISO 13616 + country_iban varchar(2), -- deprecated + cle_iban varchar(2), + domiciliation varchar(255), + state_id integer DEFAULT NULL, + fk_pays integer NOT NULL, + proprio varchar(60), + owner_address varchar(255), + courant smallint DEFAULT 0 NOT NULL, + clos smallint DEFAULT 0 NOT NULL, + rappro smallint DEFAULT 1, + url varchar(128), + account_number varchar(32), -- bank accountancy number + fk_accountancy_journal integer, -- bank accountancy journal + currency_code varchar(3) NOT NULL, + min_allowed integer DEFAULT 0, + min_desired integer DEFAULT 0, + comment text, -- TODO rename in note_private + note_public text, + model_pdf varchar(255), + import_key varchar(14) )ENGINE=innodb; From 8113e6c2f21714e81dc1a4132325129fd999f4b7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 6 May 2017 08:11:07 +0200 Subject: [PATCH 229/505] Update Accounting journal getNomUrl --- .../class/accountingjournal.class.php | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 9bff37560d7..91924f08592 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -85,27 +85,62 @@ class AccountingJournal 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 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) { - global $langs; + function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0) + { + global $langs, $conf, $user; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $link = ''; - $linkend = ''; + $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php'; $picto = 'billr'; + $label=''; - $label = $langs->trans("Show") . ': ' . $this->code . ' - ' . $this->label; + $label = '' . $langs->trans("ShowAccountingJournal") . ''; + if (! empty($this->code)) + $label .= '
    '.$langs->trans('Code') . ': ' . $this->code; + 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) - $result .= $link . $this->code . ' - ' . $this->label . $linkend; + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowAccoutingJournal"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip"'; + } + + $linkstart=''; + $linkend=''; + + if ($nourl) + { + $linkstart = ''; + $linkclose = ''; + $linkend = ''; + } + + $label_link = $this->code; + 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; } From 7c4b47f20d9e32fe753a433a5cae606c2e897854 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 6 May 2017 08:33:12 +0200 Subject: [PATCH 230/505] Update works --- htdocs/compta/bank/card.php | 18 +++++++++---- htdocs/compta/bank/class/account.class.php | 14 +++++----- htdocs/compta/bank/index.php | 27 ++++++++++++------- htdocs/compta/bank/various_payment/index.php | 4 +-- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../mysql/tables/llx_bank_account.key.sql | 2 +- htdocs/langs/en_US/accountancy.lang | 3 ++- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 75ba80052bc..804d2c5511d 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -38,6 +38,7 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categ 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 . '/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("banks"); $langs->load("bills"); @@ -100,7 +101,7 @@ if ($action == 'add') $account_number = GETPOST('account_number','alpha'); if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; } - $object->accountancy_journal = trim($_POST["accountancy_journal"]); + $object->fk_accountancy_journal = trim($_POST["fk_accountancy_journal"]); $object->solde = $_POST["solde"]; $object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); @@ -198,7 +199,7 @@ if ($action == 'update') $account_number = GETPOST('account_number', 'int'); if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; } - $object->accountancy_journal = trim($_POST["accountancy_journal"]); + $object->fk_accountancy_journal = trim($_POST["fk_accountancy_journal"]); $object->currency_code = trim($_POST["account_currency_code"]); @@ -537,7 +538,7 @@ if ($action == 'create') { print ''.$langs->trans("AccountancyJournal").''; print ''; - print $formaccountancy2->select_journal($object->accountancy_journal, 'accountancy_journal', 4, 1, '', 1, 1); + print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 1, 1); print ''; } @@ -681,7 +682,14 @@ else if (! empty($conf->accounting->enabled)) { print ''.$langs->trans("AccountancyJournal").''; - print ''.$object->accountancy_journal.''; + print ''; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($object->fk_accountancy_journal); + + print $accountingjournal->getNomUrl(0,1,1,'',1); + + print ''; } // Other attributes @@ -986,7 +994,7 @@ else { print ''.$langs->trans("AccountancyJournal").''; print ''; - print $formaccountancy2->select_journal($object->accountancy_journal, 'accountancy_journal', 4, 1, '', 1, 1); + print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 1, 1); print ''; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 897fd5de496..33181f666d7 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -160,7 +160,7 @@ class Account extends CommonObject * @var string */ public $account_number; - public $accountancy_journal; + public $fk_accountancy_journal; /** * Currency code @@ -545,7 +545,7 @@ class Account extends CommonObject $sql.= ", label"; $sql.= ", entity"; $sql.= ", account_number"; - $sql.= ", accountancy_journal"; + $sql.= ", fk_accountancy_journal"; $sql.= ", bank"; $sql.= ", code_banque"; $sql.= ", code_guichet"; @@ -569,7 +569,7 @@ class Account extends CommonObject $sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", ".$conf->entity; $sql.= ", '".$this->db->escape($this->account_number)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_journal)."'"; + $sql.= ", '".$this->db->escape($this->fk_accountancy_journal)."'"; $sql.= ", '".$this->db->escape($this->bank)."'"; $sql.= ", '".$this->code_banque."'"; $sql.= ", '".$this->code_guichet."'"; @@ -702,7 +702,7 @@ class Account extends CommonObject $sql.= ",rappro = ".$this->rappro; $sql.= ",url = ".($this->url?"'".$this->url."'":"null"); $sql.= ",account_number = '".$this->account_number."'"; - $sql.= ",accountancy_journal = '".$this->accountancy_journal."'"; + $sql.= ",fk_accountancy_journal = '".$this->fk_accountancy_journal."'"; $sql.= ",bank = '".$this->db->escape($this->bank)."'"; $sql.= ",code_banque='".$this->code_banque."'"; @@ -847,7 +847,7 @@ class Account extends CommonObject $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; - $sql.= " ba.account_number, ba.accountancy_journal, ba.currency_code,"; + $sql.= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; $sql.= " ba.min_allowed, ba.min_desired, ba.comment,"; $sql.= " ba.datec as date_creation, ba.tms as date_update,"; $sql.= ' c.code as country_code, c.label as country,'; @@ -897,7 +897,7 @@ class Account extends CommonObject $this->country = $obj->country; $this->account_number = $obj->account_number; - $this->accountancy_journal = $obj->accountancy_journal; + $this->fk_accountancy_journal = $obj->fk_accountancy_journal; $this->currency_code = $obj->currency_code; $this->account_currency_code = $obj->currency_code; @@ -1259,7 +1259,7 @@ class Account extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("accountancy"); $label .= '
    ' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - $label .= '
    ' . $langs->trans('AccountancyJournal') . ': ' . $this->accountancy_journal; + $label .= '
    ' . $langs->trans('AccountancyJournal') . ': ' . $this->fk_accountancy_journal; } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index b808fa8f596..19ec335cac5 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -29,6 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -88,7 +90,7 @@ $arrayfields=array( 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled), - 'b.accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -141,7 +143,7 @@ $title=$langs->trans('BankAccounts'); // Load array of financial accounts (opened by default) $accounts = array(); -$sql = "SELECT rowid, label, courant, rappro, account_number, accountancy_journal, datec as date_creation, tms as date_update"; +$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -323,7 +325,7 @@ if (! empty($arrayfields['b.account_number']['checked'])) print ''; } // Accountancy journal -if (! empty($arrayfields['b.accountancy_journal']['checked'])) +if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; print ''; @@ -403,7 +405,7 @@ if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titr if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'],$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['b.accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.accountancy_journal','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -488,16 +490,23 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['b.account_number']['checked'])) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - print ''.length_accountg($acc->account_number).''; + + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$acc->account_number); + + print ''.length_accountg($accountingaccount->getNomUrl(0,1,1,'',1)).''; + if (! $i) $totalarray['nbfield']++; } // Accountancy journal - if (! empty($arrayfields['b.accountancy_journal']['checked'])) + if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - print ''.length_accountg($acc->accountancy_journal).''; - if (! $i) $totalarray['nbfield']++; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($acc->fk_accountancy_journal); + + print ''.$accountingjournal->getNomUrl(0,1,1,'',1).''; + if (! $i) $totalarray['nbfield']++; } // Transactions to reconcile diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 6c4b41333f1..abf6d23d22e 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -89,7 +89,7 @@ $variousstatic = new PaymentVarious($db); $accountstatic = new Account($db); $sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel,"; +$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id"; @@ -217,7 +217,7 @@ if ($result) $accountstatic->ref=$obj->bref; $accountstatic->number=$obj->bnumber; $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; + $accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal; $accountstatic->label=$obj->blabel; print $accountstatic->getNomUrl(1); } 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 9e4699b2e4b..a9293ea6915 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 @@ -260,7 +260,7 @@ UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') ALTER TABLE llx_bank_account CHANGE COLUMN accountancy_journal fk_accountancy_journal integer; -ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); +--ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_account.key.sql b/htdocs/install/mysql/tables/llx_bank_account.key.sql index 0a168d63990..986ca7ea550 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.key.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.key.sql @@ -20,4 +20,4 @@ ALTER TABLE llx_bank_account ADD UNIQUE uk_bank_account_label (label,entity); -ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); +-- ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 9eb4135397f..92fe19676c0 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -61,7 +61,8 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account -ShowAccoutingAccount=Show accounting account +ShowAccountingAccount=Show accounting account +ShowAccountingJournal=Show accounting journal AccountAccountingSuggest=Accounting account suggested MenuDefaultAccounts=Default accounts MenuVatAccounts=Vat accounts From 55feea5d9816a3a37042fe43ea790df7cfe1f613 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sat, 6 May 2017 10:54:28 +0200 Subject: [PATCH 231/505] Update code using new css class --- htdocs/admin/stock.php | 17 +++--------- htdocs/categories/index.php | 3 +-- htdocs/categories/viewcat.php | 43 ++++++++++-------------------- htdocs/comm/card.php | 3 +-- htdocs/comm/index.php | 11 ++------ htdocs/comm/propal/stats/index.php | 5 ++-- 6 files changed, 24 insertions(+), 58 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index c8204f213c2..164e4fd6bc8 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -3,7 +3,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012-2013 Juanjo Menent - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2017 Philippe Grand * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -435,7 +435,6 @@ if ($virtualdiffersfromphysical) print '
    '; if ($conf->global->MAIN_LEVEL_FEATURES >= 2) { - $var=false; print ''; print ''; print ''."\n"; @@ -443,8 +442,7 @@ if ($conf->global->MAIN_LEVEL_FEATURES >= 2) print ''."\n"; // Example with a yes / no select - $var=!$var; - print ''; + print ''; print ''; print ''; print ''; // Example with a yes / no select - $var=!$var; - print ''; + 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").' '; @@ -457,8 +455,7 @@ if ($conf->global->MAIN_LEVEL_FEATURES >= 2) print '
    '.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; @@ -471,8 +468,7 @@ if ($conf->global->MAIN_LEVEL_FEATURES >= 2) print '
    '.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; @@ -487,7 +483,6 @@ if ($conf->global->MAIN_LEVEL_FEATURES >= 2) print '
    '; } -$var=true; print ''; print ''; @@ -509,8 +504,6 @@ if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULAT print "\n\n"; } - - print ''; print ''; print '\n"; print "\n"; - - print ''; print ''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index ca2b7b5c76f..b68da6fd597 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -112,8 +112,7 @@ if ($catname || $id > 0) $var=true; foreach ($cats as $cat) { - $var = ! $var; - print "\t\n"; + print "\t".''."\n"; print "\t\t\n"; if (count($cats) > 0) { - $var=true; foreach ($cats as $cat) - { - - print "\t\n"; + { + print "\t".''."\n"; print "\t\t".'\n"; @@ -360,11 +358,9 @@ if ($object->type == Categorie::TYPE_PRODUCT) if (count($prods) > 0) { - $var=true; foreach ($prods as $prod) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; @@ -411,12 +407,9 @@ if ($object->type == Categorie::TYPE_SUPPLIER) if (count($socs) > 0) { - $var=true; foreach ($socs as $soc) - { - - print "\t\n"; - + { + print "\t".''."\n"; print '\n"; @@ -464,14 +457,13 @@ if($object->type == Categorie::TYPE_CUSTOMER) if (count($socs) > 0) { $i = 0; - $var=true; foreach ($socs as $key => $soc) { if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself $i++; - print "\t\n"; + print "\t".''."\n"; print '\n"; @@ -520,11 +512,9 @@ if ($object->type == Categorie::TYPE_MEMBER) if (count($prods) > 0) { - $var=true; foreach ($prods as $key => $member) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; + print "\t".''."\n"; print '\n"; @@ -629,11 +618,9 @@ if ($object->type == Categorie::TYPE_ACCOUNT) if (count($accounts) > 0) { - $var=true; foreach ($accounts as $key => $account) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; @@ -684,11 +671,9 @@ if ($object->type == Categorie::TYPE_PROJECT) if (count($projects) > 0) { - $var=true; foreach ($projects as $key => $project) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index aae1398109d..b933289be4f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -788,8 +788,7 @@ if ($id > 0) while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); - $var = ! $var; - print ""; + print ''; print '"; + print ''; print ''; print ''; print ''; - print ''; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch('',$line->code_journal); + print ''; + print ''; print "\n"; $var=!$var; -print ''; +print ''; $var=!$var; From fd6518182beb1b7fbd627f3c7d567207b2fd4730 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 May 2017 12:08:43 +0200 Subject: [PATCH 244/505] Fix can force tls version --- htdocs/core/lib/geturl.lib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index da9e38e6dae..808e4f0ef09 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -59,9 +59,11 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it - // TLSv1 by default or change to TLSv1.2 in module configuration - //curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->MAIN_CURL_SSLVERSION)?1:$conf->global->MAIN_CURL_SSLVERSION)); - + // By default use tls decied by PHP. + // You can force, if supported a version like TLSv1 or TLSv1.2 + if (! empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); + //curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2 + //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); From d7d212bbe19ecc4fde6eccebe020abdd72186664 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 May 2017 12:31:37 +0200 Subject: [PATCH 245/505] Fix bad link to list --- htdocs/fourn/facture/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 52c44fc67b0..e68604fe092 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -93,7 +93,7 @@ if ($object->id > 0) $totalpaye = $object->getSommePaiement(); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
    '; // Ref supplier From dd71fdc82f26f88c202f86040baf20c753e4cc3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 May 2017 21:00:23 +0200 Subject: [PATCH 246/505] Work on modulebuilder template --- htdocs/langs/en_US/modulebuilder.lang | 4 +- htdocs/modulebuilder/index.php | 62 +- htdocs/modulebuilder/template/.editorconfig | 19 + htdocs/modulebuilder/template/.gitattributes | 23 + htdocs/modulebuilder/template/.gitignore | 16 + htdocs/modulebuilder/template/.tx/config | 9 + htdocs/modulebuilder/template/COPYING | 621 +++++ htdocs/modulebuilder/template/README.md | 221 ++ htdocs/modulebuilder/template/admin/about.php | 94 + htdocs/modulebuilder/template/admin/setup.php | 79 + .../template/build/doxygen/mymodule.doxyfile | 2419 +++++++++++++++++ .../template/build/makepack-dolibarrmodule.pl | 388 +++ .../template/build/makepack-mymodule.conf | 26 + .../template/class/MyTrigger.php | 51 + .../template/class/ParsedownDolibarr.php | 48 + .../template/class/actions_mymodule.class.php | 85 + .../template/class/myclass.class.php | 361 +++ .../template/core/boxes/mybox.php | 195 ++ .../core/modules/modMyModule.class.php | 719 +++++ .../template/core/tpl/mytemplate.tpl.php | 28 + ...terface_99_modMyModule_MyTrigger.class.php | 580 ++++ .../modulebuilder/template/css/mycss.css.php | 27 + .../template/dev/codesniffer/DolibarrPSR2.xml | 12 + .../template/dev/dolistore/README.md | 87 + .../template/dev/dolistore/keywords-de.txt | 0 .../template/dev/dolistore/keywords-en.txt | 0 .../template/dev/dolistore/keywords-es.txt | 0 .../template/dev/dolistore/keywords-fr.txt | 0 .../template/dev/dolistore/keywords-it.txt | 0 .../template/dev/dolistore/long_desc-de.html | 0 .../template/dev/dolistore/long_desc-en.html | 0 .../template/dev/dolistore/long_desc-es.html | 0 .../template/dev/dolistore/long_desc-fr.html | 0 .../template/dev/dolistore/long_desc-it.html | 0 .../template/dev/dolistore/name-de.txt | 1 + .../template/dev/dolistore/name-en.txt | 1 + .../template/dev/dolistore/name-es.txt | 1 + .../template/dev/dolistore/name-fr.txt | 1 + .../template/dev/dolistore/name-it.txt | 1 + .../template/dev/dolistore/short_desc-de.html | 0 .../template/dev/dolistore/short_desc-en.html | 0 .../template/dev/dolistore/short_desc-es.html | 0 .../template/dev/dolistore/short_desc-fr.html | 0 .../template/dev/dolistore/short_desc-it.html | 0 .../template/dev/git-hooks/post-commit | 2 + .../template/dev/git-hooks/pre-commit | 2 + .../template/dev/git-hooks/pre-push | 2 + .../modulebuilder/template/dev/img/README.md | 53 + .../template/dev/img/gfdl-129x44.png | Bin 0 -> 4709 bytes .../template/dev/img/gfdl-66x23.png | Bin 0 -> 2453 bytes .../template/dev/img/gfdl-logo.svg | 110 + .../template/dev/img/gpl-v3-logo.svg | 389 +++ .../template/dev/img/gplv3-127x51.png | Bin 0 -> 3471 bytes .../template/dev/img/gplv3-88x31.png | Bin 0 -> 2666 bytes .../template/dev/img/mymodule.svg | 70 + .../modulebuilder/template/dev/newmodule.sh | 68 + .../modulebuilder/template/doc/user/Makefile | 225 ++ .../modulebuilder/template/doc/user/make.bat | 281 ++ .../template/doc/user/source/conf.py | 428 +++ .../template/doc/user/source/index.rst | 22 + htdocs/modulebuilder/template/img/gfdl.png | Bin 0 -> 4709 bytes htdocs/modulebuilder/template/img/gplv3.png | Bin 0 -> 2666 bytes .../modulebuilder/template/img/mymodule.png | Bin 0 -> 683 bytes .../template/img/object_mymodule.png | Bin 0 -> 360 bytes htdocs/modulebuilder/template/js/myjs.js.php | 27 + .../template/langs/en_US/mymodule.lang | 51 + .../template/langs/fr_FR/mymodule.lang | 51 + .../template/lib/mymodule.lib.php | 61 + htdocs/modulebuilder/template/mypage.php | 135 + htdocs/modulebuilder/template/phpdoc.dist.xml | 30 + .../template/scripts/myscript.php | 203 ++ htdocs/modulebuilder/template/sql/data.sql | 19 + .../template/sql/llx_mytable.key.sql | 17 + .../template/sql/llx_mytable.sql | 22 + .../template/sql/update_x.x.x-y.y.y.sql | 15 + .../functional/MyModuleFunctionalTest.php | 291 ++ .../template/test/unit/MyClassTest.php | 104 + htdocs/theme/eldy/style.css.php | 5 +- 78 files changed, 8853 insertions(+), 9 deletions(-) create mode 100644 htdocs/modulebuilder/template/.editorconfig create mode 100644 htdocs/modulebuilder/template/.gitattributes create mode 100644 htdocs/modulebuilder/template/.gitignore create mode 100644 htdocs/modulebuilder/template/.tx/config create mode 100644 htdocs/modulebuilder/template/COPYING create mode 100644 htdocs/modulebuilder/template/README.md create mode 100644 htdocs/modulebuilder/template/admin/about.php create mode 100644 htdocs/modulebuilder/template/admin/setup.php create mode 100644 htdocs/modulebuilder/template/build/doxygen/mymodule.doxyfile create mode 100644 htdocs/modulebuilder/template/build/makepack-dolibarrmodule.pl create mode 100644 htdocs/modulebuilder/template/build/makepack-mymodule.conf create mode 100644 htdocs/modulebuilder/template/class/MyTrigger.php create mode 100644 htdocs/modulebuilder/template/class/ParsedownDolibarr.php create mode 100644 htdocs/modulebuilder/template/class/actions_mymodule.class.php create mode 100644 htdocs/modulebuilder/template/class/myclass.class.php create mode 100644 htdocs/modulebuilder/template/core/boxes/mybox.php create mode 100644 htdocs/modulebuilder/template/core/modules/modMyModule.class.php create mode 100644 htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php create mode 100644 htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyTrigger.class.php create mode 100644 htdocs/modulebuilder/template/css/mycss.css.php create mode 100644 htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml create mode 100644 htdocs/modulebuilder/template/dev/dolistore/README.md create mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-de.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-en.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-es.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-fr.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-it.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-de.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-en.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-es.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-fr.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-it.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-de.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-en.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-es.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-fr.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-it.txt create mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-de.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-en.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-es.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-fr.html create mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-it.html create mode 100644 htdocs/modulebuilder/template/dev/git-hooks/post-commit create mode 100644 htdocs/modulebuilder/template/dev/git-hooks/pre-commit create mode 100644 htdocs/modulebuilder/template/dev/git-hooks/pre-push create mode 100644 htdocs/modulebuilder/template/dev/img/README.md create mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-129x44.png create mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-66x23.png create mode 100644 htdocs/modulebuilder/template/dev/img/gfdl-logo.svg create mode 100644 htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg create mode 100644 htdocs/modulebuilder/template/dev/img/gplv3-127x51.png create mode 100644 htdocs/modulebuilder/template/dev/img/gplv3-88x31.png create mode 100644 htdocs/modulebuilder/template/dev/img/mymodule.svg create mode 100644 htdocs/modulebuilder/template/dev/newmodule.sh create mode 100644 htdocs/modulebuilder/template/doc/user/Makefile create mode 100644 htdocs/modulebuilder/template/doc/user/make.bat create mode 100644 htdocs/modulebuilder/template/doc/user/source/conf.py create mode 100644 htdocs/modulebuilder/template/doc/user/source/index.rst create mode 100644 htdocs/modulebuilder/template/img/gfdl.png create mode 100644 htdocs/modulebuilder/template/img/gplv3.png create mode 100644 htdocs/modulebuilder/template/img/mymodule.png create mode 100644 htdocs/modulebuilder/template/img/object_mymodule.png create mode 100644 htdocs/modulebuilder/template/js/myjs.js.php create mode 100644 htdocs/modulebuilder/template/langs/en_US/mymodule.lang create mode 100644 htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang create mode 100644 htdocs/modulebuilder/template/lib/mymodule.lib.php create mode 100644 htdocs/modulebuilder/template/mypage.php create mode 100644 htdocs/modulebuilder/template/phpdoc.dist.xml create mode 100644 htdocs/modulebuilder/template/scripts/myscript.php create mode 100644 htdocs/modulebuilder/template/sql/data.sql create mode 100644 htdocs/modulebuilder/template/sql/llx_mytable.key.sql create mode 100644 htdocs/modulebuilder/template/sql/llx_mytable.sql create mode 100644 htdocs/modulebuilder/template/sql/update_x.x.x-y.y.y.sql create mode 100644 htdocs/modulebuilder/template/test/functional/MyModuleFunctionalTest.php create mode 100644 htdocs/modulebuilder/template/test/unit/MyClassTest.php diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9979760bc4f..ef86062bbd0 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,2 +1,4 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build your own module. Your modules will be generated into the first alternative directory: %s. +ModuleBuilderDesc=This tools give you utilites to build your own module. +ModuleBuilderDesc2=Path were modules are generated (first alternative directory defined into %s): %s. +They are detected when the file %s exists in root of module directory. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 182268a5f06..38339d643c1 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -29,9 +29,43 @@ $langs->load("admin"); $langs->load("modulebuilder"); $langs->load("other"); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); + // Security check if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); +$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); + +// Dir for custom dirs +$tmp=explode(',', $dolibarr_main_document_root_alt); +$dircustom = $tmp[0]; + + + +/* + * Actions + */ + +if ($dircustom && $action == 'initmodule' && $modulename) +{ + $srcfile = DOL_DOCUMENT_ROOT.'/modulebuilder/skeletons'; + $destfile = $dircustom.'/'.$modulename; + //$result = dolCopyDir($srcfile, $destfile, 0, 0); + + dol_mkdir($destfile); + + fopen($destfile, $mode) + + if ($result > 0) + { + setEventMessages('ModuleInitialized', null); + } + else + { + setEventMessages($langs->trans("ErrorFailedToCopyDir"), null, 'errors'); + } +} /* @@ -48,14 +82,24 @@ $text=$langs->trans("ModuleBuilder"); print load_fiche_titre($text, '', 'title_setup'); -$tmp=explode(',', $dolibarr_main_document_root_alt); -$dircustom = $tmp[0]; - // Show description of content -print $langs->trans("ModuleBuilderDesc", $dircustom).'

    '; +print $langs->trans("ModuleBuilderDesc").'
    '; +print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'
    '; +print '
    '; +// New module +print '
    '; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
    '; + +$listofmodules=array(); /* if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder { @@ -73,7 +117,7 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En $fullname = $dircustom['fullname']; if (dol_is_file($fullname.'/modulebuilder.txt')) { - print '
    '.$module.'
    '; + $listofmodules[$module]=$fullname; } } } @@ -84,7 +128,11 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En $newmenu->add('', 'NoGeneratedModuleFound', 0, 0); }*/ - +foreach($listofmodules as $modules => $fullname) +{ + print '
    '.$langs->trans("UserWarehouseAutoCreate").''; @@ -523,8 +516,6 @@ print ''; print "
    '.$langs->trans("AllowAddLimitStockByWarehouse").'
    "; $categstatic->id=$cat->id; $categstatic->ref=$cat->label; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index ebd5fa9991c..d04d0baebd2 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -289,11 +289,9 @@ else print "
    '; print "".$cat->label.""; print "
    '; print $prod->getNomUrl(1); print "
    '; print $soc->getNomUrl(1); print "
    '; print $soc->getNomUrl(1); print "
    '; $member->ref=$member->login; print $member->getNomUrl(1,0); @@ -574,12 +564,11 @@ if($object->type == Categorie::TYPE_CONTACT) if (count($contacts) > 0) { $i = 0; - $var=true; foreach ($contacts as $key => $contact) { $i++; - print "\t
    '; print $contact->getNomUrl(1,'category'); print "
    '; print $account->getNomUrl(1,0); print "
    '; print $project->getNomUrl(1,0); print "
    '; $sendingstatic->id = $objp->id; $sendingstatic->ref = $objp->ref; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 4bd999b1d5a..24bccbf9c9c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -479,7 +479,6 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $resql = $db->query($sql); if ($resql) { - $var=false; $num = $db->num_rows($resql); $i = 0; @@ -544,7 +543,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $result = $db->query($sql); if ($result) { - $var=false; $num = $db->num_rows($result); $i = 0; @@ -633,11 +631,10 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $staticcontrat=new Contrat($db); - $var=false; while ($i < $num) { $obj = $db->fetch_object($resql); - print "
    contratid."\">".img_object($langs->trans("ShowContract","contract"), 'contract')." ".$obj->ref."
    contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; $companystatic->id=$objp->rowid; $companystatic->name=$objp->name; @@ -686,8 +683,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - $var=true; - print ''; print ''; @@ -785,8 +780,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - $var=true; - print '
    '.$langs->trans("ProposalsOpened").' '.$num.'
    '; print ''; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index abb24b8ffa4..5c74c8374a0 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -293,7 +293,6 @@ print ''; print ''; $oldyear=0; -$var=true; foreach ($data as $val) { $year = $val['year']; @@ -301,7 +300,7 @@ foreach ($data as $val) { // If we have empty year $oldyear--; - print ''; + print ''; print ''; print ''; print ''; @@ -311,7 +310,7 @@ foreach ($data as $val) print ''; print ''; } - print ''; + print ''; print ''; print ''; print ''; From 44bdf91715d9bf065d9e71de9f24f71299f80556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 12:43:45 +0200 Subject: [PATCH 232/505] Add badge with nb of imported calendard on user tab --- htdocs/core/lib/usergroups.lib.php | 29 +++++++++++++++++++++++------ htdocs/holiday/list.php | 2 +- htdocs/user/agenda_extsites.php | 13 ++++++------- htdocs/user/bank.php | 3 ++- htdocs/user/card.php | 2 +- htdocs/user/clicktodial.php | 3 ++- htdocs/user/document.php | 2 +- htdocs/user/info.php | 2 +- htdocs/user/ldap.php | 2 +- htdocs/user/note.php | 14 +++++++------- htdocs/user/notify/card.php | 3 ++- htdocs/user/perms.php | 2 +- 12 files changed, 48 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 8936cf98623..3b3cde1d66a 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -59,6 +59,11 @@ function user_prepare_head($object) $h++; } + $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; + $head[$h][1] = $langs->trans("UserGUISetup"); + $head[$h][2] = 'guisetup'; + $h++; + if ($canreadperms) { $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; @@ -67,15 +72,27 @@ function user_prepare_head($object) $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; - $head[$h][1] = $langs->trans("UserGUISetup"); - $head[$h][2] = 'guisetup'; - $h++; - if (! empty($conf->agenda->enabled)) { + if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; + $MAXAGENDA=$conf->global->AGENDA_EXT_NB; + + $i=1; + $nbagenda = 0; + while ($i <= $MAXAGENDA) + { + $key=$i; + $name='AGENDA_EXT_NAME_'.$object->id.'_'.$key; + $src='AGENDA_EXT_SRC_'.$object->id.'_'.$key; + $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key; + $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key; + $i++; + + if (! empty($object->conf->$name)) $nbagenda++; + } + $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id; - $head[$h][1] = $langs->trans("ExtSites"); + $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' '.$nbagenda.'' : ''); $head[$h][2] = 'extsites'; $h++; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index f91616d0b9a..d35fa9293c3 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -202,7 +202,7 @@ $user_id = $user->id; if ($id > 0) { // Charge utilisateur edite - $fuser->fetch($id); + $fuser->fetch($id, '', '', 1); $fuser->getrights(); $user_id = $fuser->id; } diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index d8aba34a934..e789a8277f3 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -42,7 +42,7 @@ $actiontest=GETPOST('test','alpha'); $actionsave=GETPOST('save','alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB; +$MAXAGENDA=$conf->global->AGENDA_EXT_NB; // List of available colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); @@ -50,7 +50,8 @@ $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5') // Security check $id = GETPOST('id','int'); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); +$object->getrights(); // Security check $socid=0; @@ -81,12 +82,12 @@ if (empty($reshook)) { if ($actionsave) { $db->begin(); - $i = 1; $errorsaved = 0; $error = 0; $tabparam = array(); // Save agendas + $i = 1; while ($i <= $MAXAGENDA) { $name = trim(GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$i, 'alpha')); $src = trim(GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$i, 'alpha')); @@ -110,7 +111,7 @@ if (empty($reshook)) { $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color; $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled; - $i ++; + $i++; } if (!$error) { @@ -167,7 +168,6 @@ print "
    \n"; $selectedvalue=$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; -$var=true; print '
    '; print "
    '.$langs->trans("OrdersOpened").' '.$num.'
    %
    0?'&userid='.$userid:'').'">'.$oldyear.'0
    0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).'
    "; @@ -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 a7e9dc1ce4b1545bc755746217b50e454e6dbcd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 13:06:33 +0200 Subject: [PATCH 233/505] Prepare 5.0.2 --- ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index c9ac46b0f2a..3d4c5a29595 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,48 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 5.0.2 compared to 5.0.1 ***** +FIX: #6468 + Fix missing translation +FIX: #6517 #6525 Autocompletion of thirdparty after n chars not implemented +FIX: #6613 Default subject for Supplier proposal emails is filled with a non-existing key +FIX: #6614 +FIX: #6619 Template invoices list do not respect restricted thirdparty user rights +FIX: #6621 Documents tab shows greyed out upload form even if the option to show actions not available is disabled +FIX: #6623 User card shows "Return to list" link even if the user has no rights to list users +FIX: #6636 Complete fix +FIX: #6669 User with no permission to edit customer invoices can see a edit button in project entry +FIX: #6671 Cannot remove thirdparty type with "#" in its name +FIX: #6673 Missing "nature" table header in thirdparty list +FIX: #6675 Restricted user with no agenda permissions can see a button to create appointment in thirdparty contact list +FIX: #6679 User with restricted supplier invoice permissions can edit project, payment conditions, payment mode +FIX: #6680 User with restricted supplier invoice permissions sees "reopen" button even if he has no permission to do it +FIX: #6718 Bug: Discount amount is not locally formatted in CommonObject View +FIX: #6767 serious critical error, no login possible with postgresql and ipv6. +FIX: #6795 #6796 +FIX: Add option MAIN_MAIL_USE_MULTI_PART to include text content into HTML email and add option MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS to restore the inline images feature. +FIX: ajax autocomplete on clone +FIX: A non admin user can not download files attached to user. +FIX: Can't download delivery receipts (function dol_check_secure_access_document) +FIX: complete hourly rate when not defined into table of time spent +FIX: dont get empty "Incoterms : - " string if no incoterm +FIX: dont lose supplier ref if no supplier price in database +FIX: Enter a direct bank transaction +FIX: extrafield css for boolean type +FIX: forgotten parameter for right multicompany use +FIX: Found duplicate line when it is not. +FIX: global $dateSelector isn't the good one, then date selector on objectline_create tpl was hidden +FIX: Journal code of bank must be visible of accountaing module on. +FIX: length_accounta return variable name +FIX: limit+1 dosn't show Total line +FIX: No filter on company when showing the link to elements. +FIX: overwrapping of weight/volume on rouget template +FIX: Several bugs in accounting module. +FIX: shared bank account with multicompany not visible in invoice setup +FIX: spaces not allowed into vat code +FIX: supplier default condition not retrieved on create +FIX: supplier order line were always created with rang = 0 + ***** ChangeLog for 5.0.1 compared to 5.0.0 ***** FIX: #6503: SQL error in "Last pending payment invoices" FIX: #6505 Project elements page shows greyed-out links even if the option to show actions not available is disabled From c4475ca9462c56eb412592afcbe859dee5e99f57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 14:56:16 +0200 Subject: [PATCH 234/505] Add a protection to avoid to take modules into custom dir. --- build/makepack-dolibarr.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index f465cf51234..061e2a18557 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -509,7 +509,6 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; # Removed known external modules to avoid any error when packaging from env where external modules are tested - #$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \;`; # For custom we want to keep dir $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`; @@ -575,6 +574,10 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/savant`; + + print "Remove subdir of custom dir\n"; + print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep dir } # Build package for each target From 880e2d0f72b951c7d64d1f6d70dd6777b554e818 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 15:05:24 +0200 Subject: [PATCH 235/505] Fix packaging 5.0.2 --- build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + 4 files changed, 4 insertions(+) diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index e65e6bc3b7d..083c4eb8f14 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -173,6 +173,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 655ef87f925..b40a203a71f 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -253,6 +253,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 55fb7183734..fa3e39f8693 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -170,6 +170,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index f7e29927ebb..b2f8cf6ede1 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -181,6 +181,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition From ab8dcbd3665fc8b4f182799dc9f7e5d47169a2fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 16:36:05 +0200 Subject: [PATCH 236/505] Use virtual name --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 061e2a18557..6959ae67623 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -19,7 +19,7 @@ use Cwd; # Change this to defined target for option 98 and 99 $PROJECT="dolibarr"; $PUBLISHSTABLE="eldy,dolibarr\@frs.sourceforge.net:/home/frs/project/dolibarr"; -$PUBLISHBETARC="ldestailleur\@asso.dolibarr.org:/home/dolibarr/dolibarr.org/httpdocs/files"; +$PUBLISHBETARC="ldestailleur\@vmprod.dolibarr.org:/home/dolibarr/dolibarr.org/httpdocs/files"; #@LISTETARGET=("TGZ","ZIP","RPM_GENERIC","RPM_FEDORA","RPM_MANDRIVA","RPM_OPENSUSE","DEB","APS","EXEDOLIWAMP","SNAPSHOT"); # Possible packages From d948447600f7d6ab6fd546b6c091bb6bf7b3dd78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 17:08:38 +0200 Subject: [PATCH 237/505] 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 238/505] 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'); ?>
    +
    Date: Sun, 7 May 2017 14:11:47 +1100 Subject: [PATCH 241/505] New-Caledonia uses the same bank accounts patterns than France --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7867f9bd753..7149d5a60a0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1359,7 +1359,7 @@ class Account extends CommonObject { $country_code=$this->getCountryCode(); - if (in_array($country_code,array('CH','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon, ... + if (in_array($country_code,array('CH','FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... if (in_array($country_code,array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... return 0; } From a3602ff6b48170db1f964031565932e5786969a0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 8 May 2017 06:20:17 +0200 Subject: [PATCH 242/505] Add journal list in new movement card --- htdocs/accountancy/bookkeeping/card.php | 66 +++++++++-------- htdocs/accountancy/bookkeeping/list.php | 9 ++- .../class/accountingjournal.class.php | 71 +++++++++++-------- .../core/class/html.formaccounting.class.php | 22 +++++- 4 files changed, 107 insertions(+), 61 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ce0bd4d3aa2..055451016e9 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * * 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 @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/bookkeeping/card.php + * \file htdocs/accountancy/bookkeeping/card.php * \ingroup Advanced accountancy - * \brief Page to show book-entry + * \brief Page to show book-entry */ require '../../main.inc.php'; @@ -28,9 +28,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; // Langs $langs->load("accountancy"); +$langs->load("bank"); +$langs->load("bills"); +$langs->load("trips"); // Security check $id = GETPOST('id', 'int'); @@ -211,6 +216,7 @@ llxHeader(); $html = new Form($db); $formventilation = new FormVentilation($db); +$formaccountancy = new FormAccounting($db); /* * Confirmation to delete the command @@ -223,26 +229,6 @@ if ($action == 'delete') { if ($action == 'create') { print load_fiche_titre($langs->trans("CreateMvts")); - $code_journal_array = array ( - $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, - $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, - $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL, - $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL, - $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL - ); - - $sql = 'SELECT DISTINCT accountancy_journal FROM ' . MAIN_DB_PREFIX . 'bank_account WHERE clos=0'; - $resql = $db->query($sql); - if (! $resql) { - setEventMessages($db->lasterror, null, 'errors'); - } else { - while ( $obj_bank = $db->fetch_object($resql) ) { - if (! empty($obj_bank->accountancy_journal)) { - $code_journal_array[$obj_bank->accountancy_journal] = $obj_bank->accountancy_journal; - } - } - } - $book = new BookKeeping($db); $next_num_mvt = $book->getNextNumMvt(); if (empty($next_num_mvt)) @@ -270,9 +256,10 @@ if ($action == 'create') { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -308,25 +295,46 @@ if ($action == 'create') { print '
    '; print '
    ' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
    '.$langs->trans("AccountancyJournal").''; + print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print '
    ' . $langs->trans("Docref") . '
    '; + print ''; print ''; print ''; print ''; + print ''; print ''; print ''; print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; + + $typelabel = $book->doc_type; + if ($typelabel == 'bank') { + $typelabel = $langs->trans('Bank'); + } + if ($typelabel == 'customer_invoice') { + $typelabel = $langs->trans('CustomerInvoice'); + } + if ($typelabel == 'supplier_invoice') { + $typelabel = $langs->trans('SupplierInvoice'); + } + if ($typelabel == 'expense_report') { + $typelabel = $langs->trans('ExpenseReport'); + } print ''; print ''; - print ''; + print ''; print ''; print '
    ' . $langs->trans("NumMvts") . '' . $book->piece_num . '
    ' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
    ' . $langs->trans("Codejournal") . '' . $book->code_journal . '
    '; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch('',$book->code_journal); + print $accountingjournal->getNomUrl(0,1,1,'',1); + print '
    ' . $langs->trans("Docref") . '' . $book->doc_ref . '
    ' . $langs->trans("Doctype") . '' . $book->doc_type . '' . $typelabel . '
    '; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 75d0a63bf39..b382d855994 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; // Langs $langs->load("accountancy"); @@ -443,7 +444,11 @@ foreach ($object->lines as $line ) { print '
    ' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . $line->code_journal . '' . $accountingjournal->getNomUrl(0,0,0,'',0) . ''; print '' . img_edit() . ' '; print '' . img_delete() . ''; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 91924f08592..168934ee5a5 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -48,45 +48,60 @@ class AccountingJournal extends CommonObject } /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ - function fetch($id) + * Load an object from database + * + * @param int $rowid Id of record to load + * @param string $journal_code Journal code + * @return int <0 if KO, Id of record if OK and found + */ + function fetch($rowid = null, $journal_code = null) { - $sql = "SELECT rowid, code, label, nature, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; - $sql.= " WHERE rowid = ".$id; - - dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ( $result ) + if ($rowid || $journal_code) { - $obj = $this->db->fetch_object($result); + $sql = "SELECT rowid, code, label, nature, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " rowid = '" . $rowid . "'"; + } elseif ($journal_code) { + $sql .= " code = '" . $journal_code . "'"; + } - $this->id = $obj->rowid; + dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); - $this->code = $obj->code; - $this->ref = $obj->code; - $this->label = $obj->label; - $this->nature = $obj->nature; - $this->active = $obj->active; + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; - return 1; - } - else - { - $this->error=$this->db->lasterror(); - return -1; + $this->code = $obj->code; + $this->ref = $obj->code; + $this->label = $obj->label; + $this->nature = $obj->nature; + $this->active = $obj->active; + + return $this->id; + } else { + return 0; + } + } + else + { + $this->error = "Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); + } } + return -1; } /** * Return clicable name (with picto eventually) * * @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 $withlabel 0=No label, 1=Include label of journal * @param int $nourl 1=Disable url * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip @@ -100,7 +115,7 @@ class AccountingJournal extends CommonObject $result = ''; - $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php'; + $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php?id=35'; $picto = 'billr'; $label=''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 1a33f0fce60..a87b566d0d6 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -51,12 +51,14 @@ class FormAccounting extends Form * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) * @param int $showempty Add an empty field * @param array $event Event options + * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code + * @param int $select_out Set value returned by select. 0=rowid (default), 1=code * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * * @return string String with HTML select */ - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') { global $conf; @@ -88,11 +90,27 @@ class FormAccounting extends Form $out = ajax_combobox($htmlname, $event); + $selected = 0; while ($obj = $this->db->fetch_object($resql)) { $label = $obj->code . ' - ' . $obj->label; + + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; + // Try to guess if we have found default value + if ($select_in == 1) { + $select_value_in = $obj->code; + } + if ($select_out == 1) { + $select_value_out = $obj->code; + } + // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } + $options[$select_value_out] = $label; } $this->db->free($resql); @@ -103,7 +121,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $select, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } From b05d2c50e8b236036ba1e944ec72b92cc33603c9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 8 May 2017 06:52:30 +0200 Subject: [PATCH 243/505] Add mode live --- htdocs/langs/en_US/stripe.lang | 3 ++- htdocs/public/stripe/config.php | 20 ++++++++++++++++---- htdocs/stripe/admin/stripe.php | 33 +++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index f19b4e44a52..3f85dc2d544 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -37,4 +37,5 @@ NewStripePaymentFailed=New Stripe payment tried but failed STRIPE_TEST_SECRET_KEY=Secret test key STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key STRIPE_LIVE_SECRET_KEY=Secret live key -STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key \ No newline at end of file +STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key +StripeLiveEnabled=Stripe live enabled \ No newline at end of file diff --git a/htdocs/public/stripe/config.php b/htdocs/public/stripe/config.php index b94617b4c69..dfd0ea6aa1a 100644 --- a/htdocs/public/stripe/config.php +++ b/htdocs/public/stripe/config.php @@ -29,9 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; //use \includes\stripe as stripe; -$stripe = array( - "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY -); +$stripe = array(); + +if(empty($conf->global->SKYPE_LIVE)) +{ + $stripe = array( + "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY + ); +} +else +{ + $stripe = array( + "secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY + ); +} \includes\stripe::setApiKey($stripe['secret_key']); \ No newline at end of file diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 1882d1065b0..6274197a301 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov * * This program is free software; you can redistribute it and/or modify @@ -45,7 +46,7 @@ if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, "STRIPE_TEST",GETPOST('STRIPE_TEST','alpha'),'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "STRIPE_LIVE",GETPOST('STRIPE_LIVE','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; @@ -76,6 +77,20 @@ if ($action == 'setvalue' && $user->admin) } } +if ($action=="setlive") +{ + $liveenable = GETPOST('value','int'); + $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable,'yesno',0,'',$conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} /* * View @@ -119,9 +134,19 @@ print ''.$langs->trans("Value").'
    '; -print $langs->trans("STRIPE_TEST").''; -print $form->selectyesno("STRIPE_TEST",$conf->global->STRIPE_TEST,1); +print '
    '; +print $langs->trans("StripeLiveEnabled").''; +if (!empty($conf->global->STRIPE_LIVE)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); +} print '