diff --git a/ChangeLog b/ChangeLog index 20c79c28ce7..ef52f808ec7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,71 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. +***** ChangeLog for 3.9.1 compared to 3.9.* ***** +FIX: #3815 Call to undefined function local_by_date() +FIX: #4424 Missing email of user popup in supplier orders area +FIX: #4442 Missing translation in Banks menu +FIX: #4737 Bank transacion type selector translation is cropped +FIX: #4742 Able to delete a supplier invoice with a registered payment +FIX: #4743 UI glitch in project summary page +FIX: #4747 Missing UI background when registering a supplier invoice payment +FIX: #4748 Supplier invoice payment confirmation amount is not translated +FIX: #4766 VAT not shown in supplier invoice popup +FIX: #4784 +FIX: #4809 Duplicate functions with different content +FIX: #4812 +FIX: #4839 +FIX: #4851 Project selector in supplier invoices shows the project label twice +FIX: #4870 +FIX: #4874 SQL error when listing users +FIX: #4880 +FIX: #4961 +FIX: #4989 +FIX: If oauth has never been activated two tables are missing and printing is not working +FIX: A not enabled field for list must not into fields to add +FIX: Bad color of message password changed +FIX: Bad error and style message when changing its own login +FIX: Bad function name call on delete +FIX: Bad include and param for project numbering module call +FIX: bad translation language loaded FIX: When changing thirdparty on event card, the showempty option of contact was lost. FIX: Bad placeholder shown on combo to select a thirdparty. +FIX: Bad vat definition when using POS module +FIX: Box disabled because bugged +FIX: Can not select a commercial on the creation of a third +FIX: Check of EAN13 barcode when mask was set to use 13 digits instead of 12 +FIX: correct display of minimum buying price +FIX: Creation of thumb image for size "small" was not done. +FIX: Damn, where was the project ref ? +FIX: Default vat is not set correctly when an error occured and we use VAT identified by a code. +FIX: dont retrieve new buying price on margin display +FIX: Duplicate records into export +FIX: Each time we edit a line, we loose the unit price. +FIX: Email templates not compatible with Multicompany +FIX: Export must use a left join to not loose lines +FIX: fetchAllEMailTemplate +FIX: Filter/search on extrafields on lists +FIX: finished parameters not used +FIX: Generated thumbs must always use the png format so using thumbs can work. +FIX: Hook resprint be printed +FIX: image extension must be in lower case +FIX: Missing clean of criteria +FIX: Missing database escaping on supplier price insert/update +FIX: Missing function +FIX: Multiprice generator didn't recalculate prices if only the price_base_type property changes +FIX: Not removing code into vatrate. +FIX: Not showing sellprice properly on product list +FIX: Parsing of amount to pay vat +FIX: PHPCS +FIX: PMP is deprecated at warehouse level +FIX: real min buying price +FIX: Same term to create than other objects +FIX: Some records were lost into margin per product report +FIX: systematic rounding causes prices to be updated without reason +FIX: Template email must take care of positino column +FIX: VAT rate can be negative. Example spain selling to morroco. +FIX: When cloning an order the order result from clone must be now +FIX: When using option Price per level, when adding a predefined product, the vat for customer was not correctly set. + + ***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. @@ -696,6 +761,23 @@ Dolibarr better: - Function get_exdir require now 6 parameters. This is to prepare a future feature. +***** ChangeLog for 3.7.4 compared to 3.7.3 ***** +FIX: #3694 +FIX: #4239 +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: #4341 +FIX: #4414 Supplier invoices use FAC_FORCE_DATE_VALIDATION client invoices property +FIX: #4440 Wrong price is filled by Product::fetch into multiprices arrays +FIX: add missing global def for ttc column +FIX: Contrat card don't consider user permissions to show active/unactive service button +FIX: CVE CVE-2015-8685 +FIX: Email templates not compatible with Multicompany +Fix: for avoid division by 0 +FIX: ISSUE #4506 : make working the PROPAL_CLONE_ON_CREATE_PAGE hidden constant +FIX: $outputlangs is not defined (dolibarr 3.7, 3.8, 3.9) +FIX: sql injection even when code is on several lines +FIX: The third dashboard don't consider user permissions + ***** ChangeLog for 3.7.3 compared to 3.7.2 ***** FIX: #3734 Do not show empty links of deleted source objects in stock movement list FIX: #3890 Expected transactions bank account page, shows negative numbers @@ -1028,6 +1110,11 @@ Dolibarr better: - Replaced USER_UPDATE_SESSION trigger with an updateSession hook may break modules using it. + +***** ChangeLog for 3.6.7 compared to 3.6.6 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: CVE CVE-2015-8685 + ***** ChangeLog for 3.6.6 compared to 3.6.5 ***** FIX: #3734 Do not show empty links of deleted source objects in stock movement list FIX: #4081 Added missing translation @@ -1280,6 +1367,17 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f - Remove add_photo_web() that is not used anymore by core code. +***** ChangeLog for 3.5.8 compared to 3.5.7 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: bad calculation for stock value +FIX: bad stock valo +FIX: change order date on clone (as everywhere else) +FIX: CVE CVE-2015-8685 +FIX: The hours of date filter aren't correct +FIX: #3442 Remove useless syslog +FIX: #3448 Pass expected date format +FIX: #3471 3.5 Rounding issue when dispatching non-integer + ***** ChangeLog for 3.5.7 compared to 3.5.6 ***** Fix: Paypal link were broken due to SSL v3 closed. Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers @@ -1845,7 +1943,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac - Fix: [ bug #810 ] Cannot update ODT template path - Fix: [ bug #816 ] Sales journal does not reflect localtaxes - Fix: [ bug #817 ] Purchases journal does not reflect localtaxes -- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionnary +- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionary - Fix: [ bug #828 ] Error when code_region is not a number in llx_c_regions (with postgres) - Fix: [ bug #855 ] Holiday approval email in French - Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email @@ -1864,7 +1962,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac - Fix: [ bug #736 ] Missing column in llx_c_chargesociales - Fix: Localtax2 for Spain must be based into buyer - Fix: [ bug #762 ] Bad profit calculation in Reporting -- Fix: bug dictionnary with wrong prefix table +- Fix: bug dictionary with wrong prefix table ***** ChangeLog for 3.3 compared to 3.2.* ***** For users: @@ -1952,7 +2050,7 @@ New experimental module: For developers: - New: Add webservice for thirdparty creation and list. - New: A module can overwrite templates parts. -- New: Can add a link on title field of added dictionnary. +- New: Can add a link on title field of added dictionary. - New: Uniformize code. - New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER. diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 834e0b07e2f..cd2ed5405db 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -216,7 +216,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -322,10 +322,25 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index abd62bc05ac..5e9fc895f0b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -168,7 +168,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates"; +$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; @@ -232,7 +232,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -$tabfield[25]= "label,type_template,position,topic,content"; +$tabfield[25]= "label,type_template,private,position,topic,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country"; @@ -264,7 +264,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "label,type_template,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country"; @@ -296,7 +296,7 @@ $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; $tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24]= "code,label"; -$tabfieldinsert[25]= "label,type_template,position,topic,content"; +$tabfieldinsert[25]= "label,type_template,private,position,topic,content,entity"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country"; @@ -585,7 +585,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); } - + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 @@ -1330,7 +1330,7 @@ if ($id) 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):'').'&id='.$id.'&'; // Favorite diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index bb3934625b6..81533de82ae 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -62,7 +62,7 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct')) { $producttmp->fetch(GETPOST('productid')); $forbarcode=$producttmp->barcode; - $fk_barcode_type=$thirdpartytmp->barcode_type_code; + $fk_barcode_type=$producttmp->barcode_type; if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 3f27d19c7f3..280f2b81908 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -59,7 +59,7 @@ exit;*/ print '
'; print '
'; -$page=GETPOST('menu','alpha'); +$page=GETPOST('menutpl','alpha'); if (empty($page)) $page='facturation'; if (in_array( diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index 6ac2915a9d1..e30a0ea3303 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -42,7 +42,7 @@ $langs->load("cashdesk"); */ //header("Content-type: text/html; charset=UTF-8"); -header("Content-type: text/html; charset=".$conf->file->character_set_client); +//header("Content-type: text/html; charset=".$conf->file->character_set_client); $arrayofjs=array(); $arrayofcss=array('/cashdesk/css/style.css'); diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index fd67bf9e2ae..240b32e34db 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -99,31 +99,24 @@ class Facturation $product = new Product($db); $product->fetch($this->id); - $sql = "SELECT taux"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva"; - $sql.= " WHERE rowid = ".$this->tva(); - - dol_syslog("ajoutArticle", LOG_DEBUG); - $resql = $db->query($sql); - - if ($resql) - { - $obj = $db->fetch_object($resql); - $vat_rate=$obj->taux; - //var_dump($vat_rate);exit; - } - else - { - dol_print_error($db); - } - + + $vatrowid = $this->tva(); + + $tmp = getTaxesFromId($vatrowid); + $vat_rate = $tmp['rate']; + $vat_npr = $tmp['npr']; + + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); + // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0,$product->type,$mysoc); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; $total_ttc = $resultarray[2]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; // Calcul du montant de la remise if ($this->remisePercent()) @@ -143,7 +136,7 @@ class Facturation $newcartarray[$i]['label']=$product->label; $newcartarray[$i]['price']=$product->price; $newcartarray[$i]['price_ttc']=$product->price_ttc; - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if (isset($product->multiprices[$societe->price_level])) @@ -160,6 +153,9 @@ class Facturation $newcartarray[$i]['remise']=price2num($montant_remise_ht); $newcartarray[$i]['total_ht']=price2num($total_ht,'MT'); $newcartarray[$i]['total_ttc']=price2num($total_ttc,'MT'); + $newcartarray[$i]['total_vat']=price2num($total_vat, 'MT'); + $newcartarray[$i]['total_localtax1']=price2num($total_localtax1, 'MT'); + $newcartarray[$i]['total_localtax2']=price2num($total_localtax2, 'MT'); $_SESSION['poscart']=$newcartarray; $this->raz(); @@ -213,12 +209,18 @@ class Facturation // Total HT $remise = $tab[$i]['remise']; $total_ht += ($tab[$i]['total_ht']); + $total_vat += ($tab[$i]['total_vat']); $total_ttc += ($tab[$i]['total_ttc']); + $total_localtax1 += ($tab[$i]['total_localtax1']); + $total_localtax2 += ($tab[$i]['total_localtax2']); } $this->prix_total_ttc = $total_ttc; $this->prix_total_ht = $total_ht; - + $this->prix_total_vat = $total_vat; + $this->prix_total_localtax1 = $total_localtax1; + $this->prix_total_localtax2 = $total_localtax2; + $this->montant_tva = $total_ttc - $total_ht; //print $this->prix_total_ttc.'eeee'; exit; } @@ -442,9 +444,8 @@ class Facturation * @param int $aTva Vat * @return int Vat */ - public function tva ( $aTva=null ) + public function tva($aTva=null) { - if ( !$aTva ) { return $this->tva; @@ -467,9 +468,8 @@ class Facturation * @param string $aNumFacture Invoice ref * @return string Invoice ref */ - public function numInvoice( $aNumFacture=null ) + public function numInvoice($aNumFacture=null) { - if ( !$aNumFacture ) { return $this->num_facture; diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 8953f7b0ccc..95a129e88a5 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -37,7 +37,7 @@ switch ( $_GET['action'] ) default: if ( $_POST['hdnSource'] != 'NULL' ) { - $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx"; + $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.recuperableonly"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; @@ -66,19 +66,23 @@ switch ( $_GET['action'] ) { $ret[$key] = $value; } + // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function + + $productid = $ret['rowid']; + $product = new Product($db); + $product->fetch($productid); - /** add Ditto for MultiPrix*/ - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $societe = new Societe($db); + $societe->fetch($thirdpartyid); + + $tva_tx = get_default_tva($mysoc,$societe,$productid); + $tva_npr = get_default_npr($mysoc,$societe,$productid); + if (empty($tva_tx)) $tva_npr=0; + dol_syslog('tva_tx='.$tva_tx.'-tva_npr='.$tva_npr); + + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($societe->price_level)) { - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $productid = $ret['rowid']; - - $societe = new Societe($db); - $societe->fetch($thirdpartyid); - - $product = new Product($db); - $product->fetch($productid); - if(isset($product->multiprices[$societe->price_level])) { $ret['price'] = $product->multiprices[$societe->price_level]; @@ -86,16 +90,39 @@ switch ( $_GET['action'] ) // $product->multiprices_min[$societe->price_level]; // $product->multiprices_min_ttc[$societe->price_level]; // $product->multiprices_base_type[$societe->price_level]; - $ret['tva_tx'] = $product->multiprices_tva_tx[$societe->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level]; + if (empty($tva_tx)) $tva_npr=0; + } } } - /** end add Ditto */ + $ret['tva_tx'] = $tva_tx; + $ret['tva_npr'] = $tva_npr; + //var_dump('tva_tx='.$ret['tva_tx'].'-tva_npr='.$ret['tva_npr'].'-'.$conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL);exit; + $obj_facturation->id($ret['rowid']); $obj_facturation->ref($ret['ref']); $obj_facturation->stock($ret['reel']); $obj_facturation->prix($ret['price']); - $obj_facturation->tva($ret['tva_tx']); + + // Use $ret['tva_tx'] / ret['tva_npr'] to find vat id + $vatrowid = null; + $sqlfindvatid = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'c_tva'; + $sqlfindvatid.= ' WHERE taux = '.$ret['tva_tx'].' AND recuperableonly = '.(int) $ret['tva_npr']; + $sqlfindvatid.= ' AND fk_pays = '.$mysoc->country_id; + $resqlfindvatid=$db->query($sqlfindvatid); + if ($resqlfindvatid) + { + $obj = $db->fetch_object($resqlfindvatid); + if ($obj) $vatrowid = $obj->rowid; + } + else dol_print_error($db); + + dol_syslog("save vatrowid=".$vatrowid); + $obj_facturation->tva($vatrowid); // Save vat it for next use // Definition du filtre pour n'afficher que le produit concerne if ( $_POST['hdnSource'] == 'LISTE' ) @@ -107,7 +134,7 @@ switch ( $_GET['action'] ) $filtre = $_POST['txtRef']; } - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$filtre; } else { @@ -115,11 +142,11 @@ switch ( $_GET['action'] ) if ( $_POST['hdnSource'] == 'REF' ) { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef']; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef']; } else { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; } } } @@ -130,40 +157,38 @@ switch ( $_GET['action'] ) } else { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; } break; case 'ajout_article': // We have clicked on button "Add product" - //var_dump('ajout_article'); - //exit; - if (! empty($obj_facturation->id)) // A product was previously selected and stored in session, so we can add it { + dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); - $obj_facturation->tva($_POST['selTva']); + $obj_facturation->tva($_POST['selTva']); // Save VAT selected so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); $obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart'] // We update prixTotalTtc } - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; break; case 'suppr_article': $obj_facturation->supprArticle($_GET['suppr_id']); - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; break; } // We saved object obj_facturation $_SESSION['serObjFacturation'] = serialize($obj_facturation); - +//var_dump($_SESSION['serObjFacturation']); header('Location: '.$redirection); exit; diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index db80866a77f..238a73f6ef7 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -125,7 +125,7 @@ if ( $retour >= 0 ) $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); //var_dump($_SESSION);exit; - header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&id=NOUV'); + header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); exit; } else diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index f9ef89e909c..ecb11c3e6ee 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -119,7 +119,7 @@ $langs->load("cashdesk"); - + @@ -128,16 +128,17 @@ $langs->load("cashdesk"); diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php index ce38bb7d7e8..745ea723b49 100644 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ b/htdocs/cashdesk/tpl/menu.tpl.php @@ -62,7 +62,7 @@ $langs->load("main"); print ''; } - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - $titlesellprice=$langs->trans("SellingPrice"); - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - $titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); - } - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print ''; @@ -423,7 +424,7 @@ else if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desirestock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 6c99461b353..ca351f7d1bb 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -508,7 +508,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) $file = $reg[1]; $classname = substr($file,4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c6511e2a67d..af4a4c7299f 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -352,7 +352,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - setEventMessagess($langs->trans("RecordDeleted"), null, 'mesgs'); + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: index.php"); exit; } @@ -535,7 +535,7 @@ if ($action == 'create' && $user->rights->projet->creer) dol_fiche_end(); print '
'; - print ''; + print ''; if (! empty($backtopage)) { print '     '; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7548f4f2e0a..7f8aa6252e8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1146,14 +1146,21 @@ class Project extends CommonObject //Generate next ref $defaultref=''; $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; - if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php")) + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) { - - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.'.php'; - $modProject = new $obj; - $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty->id:0,$clone_project); + $file=dol_buildpath($reldir."core/modules/project/".$obj.'.php',0); + if (file_exists($file)) + { + $filefound=1; + dol_include_once($reldir."core/modules/project/".$obj.'.php'); + $modProject = new $obj; + $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty:null, $clone_project); + break; + } } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; $clone_project->ref=$defaultref; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3839a9b0b06..d71b3aa6ebe 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -348,8 +348,7 @@ $langs->load("orders"); $langs->load("proposals"); $langs->load("margins"); -//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy'); -print '
'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'

'; +print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); print '
'; print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9ae3513fa8a..f520e7ba1a6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -106,7 +106,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('project'); +$extralabels = $extrafields->fetch_name_optionals_label('projet'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -218,16 +218,15 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; - // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_user > 0) { $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; } - $sql.= " WHERE p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser @@ -274,6 +273,19 @@ if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; if ($search_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_user; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -481,10 +493,25 @@ if ($resql) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } } - } - // Fields from hook + } + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e140ee2f672..0f955484bfe 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -66,7 +66,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('project'); +$extralabels = $extrafields->fetch_name_optionals_label('projet_task'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Security check @@ -226,6 +226,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid,"; $sql.= " ".MAIN_DB_PREFIX."projet_task as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as ef on (t.rowid = ef.fk_object)"; if ($search_project_user > 0) { $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; @@ -275,6 +276,19 @@ if ($search_projectstatus >= 0) $sql .= " AND p.fk_statut = ".$db->escape($searc if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -478,14 +492,29 @@ if ($resql) if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; if (! empty($arrayfields['t.progress']['checked'])) print ''; - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } } - } + } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index feaed5d9f7d..621a8988a04 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -5,9 +5,6 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Ferran Marcet * - * Version V1.1 Initial version of Philippe Berthet - * Version V2 Change to be compatible with 3.4 and enhanced to be more generic - * * 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 @@ -79,6 +76,7 @@ $langs->load("suppliers"); $langs->load("propal"); $langs->load("interventions"); $langs->load("contracts"); +$langs->load("products"); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('consumptionthirdparty')); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 087195e2905..80e54742765 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -101,7 +101,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('thirdparty'); +$extralabels = $extrafields->fetch_name_optionals_label('societe'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -170,7 +170,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } - /* @@ -200,6 +199,7 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { + $search_nom=''; $search_categ=''; $search_sale=''; $search_barcode=""; @@ -346,7 +346,7 @@ if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_soc"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook @@ -401,7 +401,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -592,35 +592,35 @@ if ($resql) { print ''; } // Barcode if (! empty($arrayfields['s.barcode']['checked'])) { print ''; } // Customer code if (! empty($arrayfields['s.code_client']['checked'])) { print ''; } // Supplier code if (! empty($arrayfields['s.code_fournisseur']['checked'])) { print ''; } // Account Customer code if (! empty($arrayfields['s.code_compta']['checked'])) { print ''; } // Account Supplier code @@ -634,14 +634,14 @@ if ($resql) if (! empty($arrayfields['s.town']['checked'])) { print ''; } // Zip if (! empty($arrayfields['s.zip']['checked'])) { print ''; } // Country @@ -662,42 +662,42 @@ if ($resql) { // IdProf1 print ''; } if (! empty($arrayfields['s.siret']['checked'])) { // IdProf2 print ''; } if (! empty($arrayfields['s.ape']['checked'])) { // IdProf3 print ''; } if (! empty($arrayfields['s.idprof4']['checked'])) { // IdProf4 print ''; } if (! empty($arrayfields['s.idprof5']['checked'])) { // IdProf5 print ''; } if (! empty($arrayfields['s.idprof6']['checked'])) { // IdProf6 print ''; } @@ -759,7 +759,18 @@ if ($resql) { if (! empty($arrayfields["ef.".$key]['checked'])) { - print ''; } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b492bc3725f..cb4f65abeed 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Patrick Raguin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2011-2013 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García @@ -1211,7 +1211,7 @@ else print ''; print ''; print ''; } @@ -1885,7 +1885,7 @@ else 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 1, 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') ) ); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4d5ae4a3ba3..f474c4463d8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -103,7 +103,7 @@ $useboldtitle=1; if (! isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY=$colorbackbody; if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1='120,130,170'; if (! isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1=$colorbacktitle1; -if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER=='238,246,252'; +if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER='238,246,252'; if (! isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB=$colortexttitlenotab; if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK=$colortextlink; @@ -2893,12 +2893,10 @@ table.valid { border-radius: 4px; } #tiptip_content { --moz-border-radius:0px; --webkit-border-radius: 0px; -border-radius: 0px; -background-color: rgb(255,255,255); -/* background-color: rgb(255,255,255); - background-color: rgba(255,255,255,0.95);*/ + -moz-border-radius:0px; + -webkit-border-radius: 0px; + border-radius: 0px; + background-color: rgb(255,255,255); line-height: 1.4em; min-width: 200px; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dd424a9e0e6..b0425b182e0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,12 +3,12 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) * @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->ldap_sid = GETPOST("ldap_sid"); $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; $object->employee = GETPOST('employee'); - + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; @@ -249,15 +249,15 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; - } + } else { $langs->load("errors"); $db->rollback(); - if (is_array($object->errors) && count($object->errors)) + if (is_array($object->errors) && count($object->errors)) { setEventMessages($object->error, $object->errors, 'errors'); - } + } $action = "create"; // Go back to create page } } @@ -283,8 +283,8 @@ if (empty($reshook)) { if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -298,220 +298,204 @@ if (empty($reshook)) { { $error = 0; - if (!$_POST["lastname"]) { - setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } - if (!$_POST["login"]) { - setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } + if (!$_POST["lastname"]) { + setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } + if (!$_POST["login"]) { + setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } - if (!$error) { - $object->fetch($id); + if (!$error) { + $object->fetch($id); - $object->oldcopy = clone $object; + $object->oldcopy = clone $object; - if (!$error) { - $db->begin(); + if (!$error) { + $db->begin(); - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $object->pass = GETPOST("password"); - $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; - $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin - $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id', 'int'); - $object->state_id = GETPOST('state_id', 'int'); - $object->office_phone = GETPOST("office_phone", 'alpha'); - $object->office_fax = GETPOST("office_fax", 'alpha'); - $object->user_mobile = GETPOST("user_mobile"); - $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); - $object->job = GETPOST("job", 'alpha'); - $object->signature = GETPOST("signature"); - $object->accountancy_code = GETPOST("accountancy_code"); - $object->openid = GETPOST("openid"); - $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - $object->employee = GETPOST('employee'); - - $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; - $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; - $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; - $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; - $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->login = GETPOST("login", 'alpha'); + $object->gender = GETPOST("gender", 'alpha'); + $object->pass = GETPOST("password"); + $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; + $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); + $object->office_phone = GETPOST("office_phone", 'alpha'); + $object->office_fax = GETPOST("office_fax", 'alpha'); + $object->user_mobile = GETPOST("user_mobile"); + $object->skype = GETPOST("skype", 'alpha'); + $object->email = GETPOST("email", 'alpha'); + $object->job = GETPOST("job", 'alpha'); + $object->signature = GETPOST("signature"); + $object->accountancy_code = GETPOST("accountancy_code"); + $object->openid = GETPOST("openid"); + $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; + $object->employee = GETPOST('employee'); - if (! empty($conf->multicompany->enabled)) - { - if (! empty($_POST["superadmin"])) - { - $object->entity = 0; - } - else if ($conf->multicompany->transverse_mode) - { - $object->entity = 1; // all users in master entity - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; + $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; + $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; + $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; + $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } + $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; - if (!empty($conf->multicompany->enabled)) { - if (!empty($_POST["superadmin"])) { - $object->entity = 0; - } else { - if ($conf->multicompany->transverse_mode) { - $object->entity = 1; // all users in master entity - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } - } - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } + if (! empty($conf->multicompany->enabled)) + { + if (! empty($_POST["superadmin"])) + { + $object->entity = 0; + } + else if ($conf->multicompany->transverse_mode) + { + $object->entity = 1; // all users in master entity + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } - if (GETPOST('deletephoto')) { - $object->photo = ''; - } - if (!empty($_FILES['photo']['name'])) { - $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } - if (!$error) { - $ret = $object->update($user); - if ($ret < 0) { - $error ++; - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors'); - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if (GETPOST('deletephoto')) { + $object->photo = ''; + } + if (!empty($_FILES['photo']['name'])) { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + } - if (!$error && isset($_POST['contactid'])) { - $contactid = GETPOST('contactid'); + if (!$error) { + $ret = $object->update($user); + if ($ret < 0) { + $error ++; + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - if ($contactid > 0) { - $contact = new Contact($db); - $contact->fetch($contactid); + if (!$error && isset($_POST['contactid'])) { + $contactid = GETPOST('contactid', 'int'); - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=".$db->escape($contactid); - if ($contact->socid) { - $sql .= ", fk_soc=".$db->escape($contact->socid); - } - $sql .= " WHERE rowid=".$object->id; - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; - $sql .= " WHERE rowid=".$object->id; - } - dol_syslog("fiche::update", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - } + if ($contactid > 0) { + $contact = new Contact($db); + $contact->fetch($contactid); - if (!$error && !count($object->errors)) { - if (GETPOST('deletephoto') && $object->photo) { - $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; - $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=".$db->escape($contactid); + if (!empty($contact->socid)) { + $sql .= ", fk_soc=".$db->escape($contact->socid); + } + $sql .= " WHERE rowid=".$object->id; + } else { + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; + $sql .= " WHERE rowid=".$object->id; + } + dol_syslog("usercard::update", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + } - if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); + if (!$error && !count($object->errors)) { + if (GETPOST('deletephoto') && $object->photo) { + $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; + $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } - dol_mkdir($dir); + if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { + $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); - if (@is_dir($dir)) { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); + dol_mkdir($dir); - if (!$result > 0) { - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + if (@is_dir($dir)) { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); - } - } else { - $error ++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } - } + if (!$result > 0) { + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } else { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); - if (!$error && !count($object->errors)) { - setEventMessages($langs->trans("UserModified"), null, 'mesgs'); - $db->commit(); + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } + } else { + $error ++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); + } + } + } - $login = $_SESSION["dol_login"]; - if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login - { - $error++; - $langs->load("errors"); - setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } else { - $db->rollback(); - } - } - } else { - if ($caneditpassword) // Case we can edit only password - { - $object->fetch($id); + if (!$error && !count($object->errors)) { + setEventMessages($langs->trans("UserModified"), null, 'mesgs'); + $db->commit(); - $object->oldcopy = dol_clone($object); - - $ret = $object->setPassword($user, $_POST["password"]); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } - - $object->oldcopy = clone $object; - - $ret=$object->setPassword($user,$_POST["password"]); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $login = $_SESSION["dol_login"]; + if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login + { + $error++; + $langs->load("errors"); + setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings'); + } + } else { + $db->rollback(); + } + } + } + } + else + { + if ($caneditpassword) // Case we can edit only password + { + dol_syslog("Not allowed to change fields, only password"); + + $object->fetch($id); + + $object->oldcopy = clone $object; + + $ret = $object->setPassword($user, GETPOST("password")); + if ($ret < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + } // Change password with a new generated one if ((($action == 'confirm_password' && $confirm == 'yes') @@ -526,18 +510,18 @@ if (empty($reshook)) { } else { // Succes if ($action == 'confirm_passwordsend' && $confirm == 'yes') { - if ($object->send_password($user, $newpassword) > 0) + if ($object->send_password($user, $newpassword) > 0) { setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs'); - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else + } + else { - setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'errors'); + setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'warnings'); } } } @@ -589,8 +573,8 @@ if (empty($reshook)) { $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } } - } - else + } + else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } @@ -921,7 +905,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print $formcompany->select_state($object->state_id,$object->country_code, 'state_id'); print ''; } - + // Tel print ''; print '\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''; print '\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''; print ''; @@ -1749,13 +1733,14 @@ else dol_fiche_head($head, 'user', $title, 0, 'user'); - $rowspan=17; + $rowspan=22; if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; if (! empty($conf->skype->enabled)) $rowspan++; if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3; if (! empty($conf->agenda->enabled)) $rowspan++; + if (! empty($conf->accounting->enabled)) $rowspan++; print '
'; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } print '
'.fieldLabel('AllocateCommercial','commercial_id').''; - $form->select_dolusers((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default + print $form->select_dolusers((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default print '
'.$langs->trans("PhonePro").''; @@ -1065,7 +1049,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print "
'.$langs->trans("AccountancyCode").''; @@ -1402,7 +1386,7 @@ else print "
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'; @@ -2173,7 +2158,7 @@ else print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ""; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7307590016a..1ee07e0a7af 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -4,7 +4,7 @@ * Copyright (c) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2013-2014 Philippe Grand @@ -138,11 +138,11 @@ class User extends CommonObject // For cache usage $this->all_permissions_are_loaded = 0; - - // Force some default values + + // Force some default values $this->admin = 0; $this->employee = 1; - + $this->conf = new stdClass(); $this->rights = new stdClass(); $this->rights->user = new stdClass(); @@ -162,7 +162,7 @@ class User extends CommonObject */ function fetch($id='', $login='',$sid='',$loadpersonalconf=1, $entity=-1) { - global $langs, $conf, $user; + global $conf, $user; // Clean parameters $login=trim($login); @@ -202,14 +202,17 @@ class User extends CommonObject } else { - $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } } else // The fetch was forced on an entity { - $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; + if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + else + $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; } - + if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba { $sql.= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1"; @@ -239,7 +242,7 @@ class User extends CommonObject $this->ldap_sid = $obj->ldap_sid; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; - + $this->employee = $obj->employee; $this->login = $obj->login; @@ -256,7 +259,7 @@ class User extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; @@ -298,8 +301,8 @@ class User extends CommonObject // Protection when module multicompany was set, admin was set to first entity and the module disabled, // then this admin user must be admin for all entities. - if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; - + if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -1227,7 +1230,7 @@ class User extends CommonObject $this->error = $langs->trans("ErrorFieldRequired",$this->login); return -1; } - + $this->db->begin(); // Update datas @@ -1272,7 +1275,7 @@ class User extends CommonObject $nbrowsaffected+=$this->db->affected_rows($resql); // Update password - if ($this->pass) + if (!empty($this->pass)) { if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { @@ -1893,7 +1896,7 @@ class User extends CommonObject global $menumanager; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; - + $result = ''; $companylink = ''; $link = ''; @@ -1947,11 +1950,11 @@ class User extends CommonObject $link.= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label=$langs->trans("ShowUser"); - $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $link.= ' title="'.dol_escape_htmltag($label, 1).'"'; $link.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; @@ -1969,7 +1972,7 @@ class User extends CommonObject else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'
'; $result.=$picto; } - if (abs($withpictoimg) != 2) + if (abs($withpictoimg) != 2) { if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen); @@ -2582,8 +2585,8 @@ class User extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - + + /** * Charge indicateurs this->nb pour le tableau de bord * @@ -2618,6 +2621,6 @@ class User extends CommonObject return -1; } } - + } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index d0ac0aaa66d..b5b2de41c56 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro + * 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 @@ -175,7 +176,7 @@ $sql.= " u.tms as date_update, u.datec as date_creation,"; $sql.= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2,"; $sql.= " s.nom as name, s.canvas"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook @@ -201,7 +202,9 @@ if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); if ($search_gender != '' && $search_gender != '-1') $sql.= " AND u.gender = '".$search_gender."'"; -if ($search_employee >= 0) $sql.= natural_search("u.employee", $search_employee); +if (is_numeric($search_employee) && $search_employee >= 0) { + $sql .= ' AND u.employee = '.(int) $search_employee; +} if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_email != '') $sql.= natural_search("u.email", $search_email); if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; @@ -213,7 +216,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -368,7 +371,22 @@ if ($result) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) print '
'; + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } } } // Fields from hook diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 2e3314fff12..43facbb24fa 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"];
'.$langs->trans("AccountancyCode").''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print '