diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index f904c7f6cf0..ea745e45df7 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -256,7 +256,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"; @@ -293,7 +293,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"; @@ -644,7 +644,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 @@ -1409,7 +1409,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/admin/menus/other.php b/htdocs/admin/menus/other.php index 73dc0fe3b85..471edf58e79 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -50,25 +50,11 @@ else if ($action == 'disable_hidemenu') exit; } -if ($action == 'activate_layoutmenu') -{ - dolibarr_set_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT", '1','chaine',0,'',$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} -else if ($action == 'disable_layoutmenu') -{ - dolibarr_del_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT",$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} - /* * View */ - llxHeader('',$langs->trans("Setup")); print load_fiche_titre($langs->trans("Menus"),'','title_setup'); @@ -119,25 +105,6 @@ else print ""; print ''; -// Use a flip-hide menu -if (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 1) -{ - $var=!$var; - print ""; - print ''.$langs->trans("MenuUseLayout").''; - print ''; - if (empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } - print ""; - print ''; -} - print ''; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b1ad347d8b7..bd49265436d 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + // Translations $langs->load("multicurrency"); @@ -41,10 +42,11 @@ if (! $user->admin) { // Parameters $action = GETPOST('action', 'alpha'); - /* * Actions */ + + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -64,7 +66,7 @@ if (preg_match('/del_(.*)/',$action,$reg)) $code=$reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else @@ -117,6 +119,21 @@ elseif ($action == 'update_currency') } } } +elseif ($action == 'synchronize') +{ + $response = GETPOST('response'); + $response = json_decode($response); + + if ($response->success) + { + MultiCurrency::syncRates($response); + } + else + { + setEventMessages($langs->trans('multicurrency_syncronize_error', $reponse->error->info), null, 'errors'); + } +} + $TCurrency = array(); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; @@ -136,7 +153,7 @@ if ($resql) * View */ -$page_name = "MultiCurrency"; +$page_name = "MultiCurrencySetup"; llxHeader('', $langs->trans($page_name)); @@ -212,42 +229,72 @@ print ''; print '
'; print ''; print ''; -print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY')); -print ''; -print '
'; -print ''; - -$var=!$var; -print ''; -print ''.$langs->transnoentitiesnoconv("multicurrency_appId").''; -print ' '; -print ''; -print '
'; -print ''; -print ''; -print ' '; -print ''; -print '
'; -print ''; - -$var=!$var; -print ''; -print ''.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").''; -print ' '; -print ''; -print '
'; -print ''; -print ''; -print ' '; // CURRENCY_BASE - CURRENCY_ENTITY - ID_ENTITY +print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'), $conf->global->MULTICURRENCY_MODIFY_RATE_APPLICATION); print ''; print '
'; print ''; print ''; - -print ''; - print '
'; + +$var=false; +print ''; +print ''; +print ''."\n"; +print ''; +print ''; + + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +/* This property seems not used in code, so i comment it +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; +*/ + +print '
'.$langs->trans("CurrencyLayerAccount").' '; +print '
'; +print ''; +print ''; +print $langs->trans("Value").' '; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_appId").' '; +print '
'; +print ''; +print ''; +print ' '; +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").' '; +print '
'; +print ''; +print ''; +print ' '; // Default: USD +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").' '; +print '
'; +print ''; +print ''; +print ' '; // Example: EUR +print ''; +print '
'; +print '
'; +print '
'; + print ''; print ''; @@ -287,6 +334,26 @@ foreach ($TCurrency as &$currency) print '
'; + + +print ' + +'; + llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index dea894a0258..d05f9078828 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -911,6 +911,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1040,6 +1041,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1325,7 +1327,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { @@ -1465,7 +1467,7 @@ if ($action == 'create') print ''.fieldLabel('Currency','multicurrency_code').''; print ''; $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 1); print ''; } @@ -1978,9 +1980,9 @@ if ($action == 'create') print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9b5c29f55db..db80893f426 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -833,6 +833,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -963,6 +964,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -2205,9 +2207,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index f86ac81aa76..f0c8a6bcdda 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -223,7 +223,7 @@ if ($resql) print ' '; print ' '; print ''; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8); + $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1); print ''; print ''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00498b870a7..491c4ca041a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1522,6 +1522,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1682,6 +1683,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -3516,9 +3518,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 4d5de55e384..0f513412a93 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud + * 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 @@ -214,7 +215,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) */ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.tva as total_tva, f.total_ttc, f.type"; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; $sql.= ", s.code_fournisseur"; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index daf43ec9d64..9e81180c4fe 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -563,6 +563,18 @@ class Paiement extends CommonObject } } + // Add link 'WithdrawalPayment' in bank_url + if (! $error && $label == '(WithdrawalPayment)') + { + $result=$acc->add_url_line( + $bank_line_id, + $this->id_prelevement, + DOL_URL_ROOT.'/compta/prelevement/card.php?id=', + $this->num_paiement, + 'withdraw' + ); + } + if (! $error && ! $notrigger) { // Appel des triggers diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3c3a7d14ca0..31d9e4d67c1 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -462,6 +462,7 @@ class BonPrelevement extends CommonObject $paiement->amounts = $amounts; $paiement->paiementid = 3; // $paiement->num_paiement = $this->ref ; + $paiement->id_prelevement = $this->id ; $paiement_id = $paiement->create($user); if ($paiement_id < 0) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b38787a4067..36c79c0f7c5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -621,6 +621,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 082f362458b..4c32664630f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -902,7 +902,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') + * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -3779,7 +3779,7 @@ class Form print ''; print ''; print ''; print ''; print '
'; - print $this->selectMultiCurrency($selected,$htmlname); + print $this->selectMultiCurrency($selected, $htmlname, 1); print '
'; @@ -3797,11 +3797,13 @@ class Form * @param string $page Page * @param double $rate Current rate * @param string $htmlname Name of select html field + * @param string $currency Currency code to explain the rate * @return void */ - function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx') + function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx', $currency='') { - global $langs; + global $langs, $mysoc, $conf; + if ($htmlname != "none") { print '
'; @@ -3816,7 +3818,15 @@ class Form } else { - print !empty($rate) ? price(price2num($rate), 1, $langs) : 1; + if (! empty($rate)) + { + print price($rate, 1, $langs, 1, 0); + if ($currency && $rate != 1) print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; + } + else + { + print 1; + } } } @@ -4030,17 +4040,17 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0) + function selectMultiCurrency($selected='', $htmlname='multicurrency_code', $useempty=0) { global $db,$conf,$langs,$user; - $langs->loadCacheCurrencies(''); + $langs->loadCacheCurrencies(''); // Load ->cache_currencies $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; $resql = $db->query($sql); - if ($resql) { while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; @@ -4048,14 +4058,14 @@ class Form $out=''; $out.= ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a23078a0e12..46b485d8a3c 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -334,7 +334,7 @@ class FormMail extends Form $out.= '   '; $out.= ''; } - + $out.= ''."\n"; @@ -876,13 +876,13 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT rowid, label, topic, content, lang"; + $sql = "SELECT rowid, label, topic, content, lang, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; $sql.= " AND entity IN (".getEntity("c_email_templates").")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label","ASC"); + $sql.= $this->db->order("position,lang,label","ASC"); //print $sql; $resql = $this->db->query($sql); @@ -896,7 +896,7 @@ class FormMail extends Form $line->id=$obj->rowid; $line->label=$obj->label; $line->topic=$obj->topic; - $line->content=$obj->lacontentbel; + $line->content=$obj->content; $line->lang=$obj->lang; $this->lines_model[]=$line; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 8ecde98aaa4..c532fd799bd 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -188,7 +188,7 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18).' - '.$obj->title; + $labeltoshow=dol_trunc($obj->ref,18); //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d1df6fcb6e5..899635e403e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1040,6 +1040,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("withdrawals"); $langs->load("banks"); $langs->load("bills"); + $langs->load('categories'); // Bank-Caisse if (! empty($conf->banque->enabled)) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index da59679b1be..895ed6de89d 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * 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 @@ -49,6 +49,7 @@ class ImportCsv extends ModeleImports var $separator; + var $file; // Path of file var $handle; // Handle fichier var $cacheconvert=array(); // Array to cache list of value found after a convertion @@ -85,76 +86,6 @@ class ImportCsv extends ModeleImports if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); } - /** - * getDriverId - * - * @return string Id - */ - function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Label - */ - function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string Description - */ - function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string Driver suffix - */ - function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string Driver version - */ - function getDriverVersion() - { - return $this->version; - } - - /** - * getDriverLabel - * - * @return string Label of external lib - */ - function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string Version of external lib - */ - function getLibVersion() - { - return $this->version_lib; - } - /** * Output header of an example file for this format @@ -236,6 +167,19 @@ class ImportCsv extends ModeleImports return $ret; } + + /** + * Return nb of records. File must be closed. + * + * @param string $file Path of filename + * @return int <0 if KO, >=0 if OK + */ + function import_get_nb_of_lines($file) + { + return dol_count_nb_of_line($file); + } + + /** * Input header line from file * @@ -319,7 +263,7 @@ class ImportCsv extends ModeleImports * * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...) + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key * @return int <0 if KO, >0 if OK @@ -401,7 +345,7 @@ class ImportCsv extends ModeleImports // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval=='')) + if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval=='')) { $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); $this->errors[$error]['type']='NOTNULL'; @@ -420,7 +364,13 @@ class ImportCsv extends ModeleImports || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' ) { - if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor + // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. + $isidorref='id'; + if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; + $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref + //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + + if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { $file=$objimport->array_import_convertvalue[0][$val]['classfile']; $class=$objimport->array_import_convertvalue[0][$val]['class']; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 637cf35cc79..627fcfd6fd9 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * 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 @@ -49,6 +49,7 @@ class Importxlsx extends ModeleImports var $separator; + var $file; // Path of file var $handle; // Handle fichier var $cacheconvert=array(); // Array to cache list of value found after a convertion @@ -72,100 +73,29 @@ class Importxlsx extends ModeleImports // this is used as an extension from the example file code, so we have to put xlsx here !!! $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php - $this->label='Excel'; // Label of driver - $this->desc=$langs->trans("ExcelFormatDesc",$this->separator,$this->enclosure,$this->escape); + $this->label='Excel 2007'; // Label of driver + $this->desc=$langs->trans("Excel2007FormatDesc"); $this->extension='xlsx'; // Extension for generated file by this driver $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version='1.0'; // Driver version // If driver use an external library, put its name here - require_once PHPEXCEL_PATH.'PHPExcel.php'; + require_once PHPEXCEL_PATH.'PHPExcel.php'; require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive - { + if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive + { $langs->load("errors"); $this->error=$langs->trans('ErrorPHPNeedModule','zip'); return -1; - } - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; + } + $this->label_lib='PhpExcel'; + $this->version_lib='1.8.0'; $this->datatoimport=$datatoimport; if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); } -// Those Get methods should all be in the parent class !!! - /** - * getDriverId - * - * @return string Id - */ - function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Label - */ - function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string Description - */ - function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string Driver suffix - */ - function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string Driver version - */ - function getDriverVersion() - { - return $this->version; - } - - /** - * getDriverLabel - * - * @return string Label of external lib - */ - function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string Version of external lib - */ - function getLibVersion() - { - return $this->version_lib; - } - - + /** * Output header of an example file for this format * @@ -276,9 +206,32 @@ class Importxlsx extends ModeleImports $reader = new PHPExcel_Reader_Excel2007(); $this->workbook = $reader->load($file); $this->record = 1; + $this->file = $file; + return $ret; } + + /** + * Return nb of records. File must be closed. + * + * @param string $file Path of filename + * @return int <0 if KO, >=0 if OK + */ + function import_get_nb_of_lines($file) + { + $reader = new PHPExcel_Reader_Excel2007(); + $this->workbook = $reader->load($file); + + $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); + + $this->workbook->disconnectWorksheets(); + unset($this->workbook); + + return $rowcount; + } + + /** * Input header line from file * @@ -336,7 +289,7 @@ class Importxlsx extends ModeleImports * * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...) + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key * @return int <0 if KO, >0 if OK @@ -419,7 +372,7 @@ class Importxlsx extends ModeleImports // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval=='')) + if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); $this->errors[$error]['type']='NOTNULL'; @@ -438,7 +391,13 @@ class Importxlsx extends ModeleImports || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' ) { - if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor + // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. + $isidorref='id'; + if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; + $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref + //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + + if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { $file=$objimport->array_import_convertvalue[0][$val]['classfile']; $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -645,7 +604,8 @@ class Importxlsx extends ModeleImports } if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id; $sql.=')'; -print($sql); + + //print($sql).'
'; dol_syslog("import_csv.modules", LOG_DEBUG); //print '> '.join(',',$arrayrecord); diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index a27b0fd9426..11b81ecb820 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -59,6 +59,78 @@ class ModeleImports { } + + /** + * getDriverId + * + * @return string Id + */ + function getDriverId() + { + return $this->id; + } + + /** + * getDriverLabel + * + * @return string Label + */ + function getDriverLabel() + { + return $this->label; + } + + /** + * getDriverDesc + * + * @return string Description + */ + function getDriverDesc() + { + return $this->desc; + } + + /** + * getDriverExtension + * + * @return string Driver suffix + */ + function getDriverExtension() + { + return $this->extension; + } + + /** + * getDriverVersion + * + * @return string Driver version + */ + function getDriverVersion() + { + return $this->version; + } + + /** + * getDriverLabel + * + * @return string Label of external lib + */ + function getLibLabel() + { + return $this->label_lib; + } + + /** + * getLibVersion + * + * @return string Version of external lib + */ + function getLibVersion() + { + return $this->version_lib; + } + + /** * Charge en memoire et renvoie la liste des modeles actifs * diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ad4c2bba16a..17141b6200d 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -45,6 +45,7 @@ class modCategorie extends DolibarrModules $this->numero = 1780; $this->family = "technic"; + $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 categories (produits, clients, fournisseurs...)"; @@ -53,7 +54,7 @@ class modCategorie extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; + $this->special = 0; $this->picto = 'category'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 9111ec11099..0648eb8bf0b 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -45,7 +45,7 @@ class modDocumentGeneration extends DolibarrModules $this->numero = 1520; $this->family = "technic"; - $this->module_position = 10000; + $this->module_position = 80; // 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 = "Direct mail document generation"; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index cb3d104e096..e8a6baa8509 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -44,7 +44,7 @@ class modExport extends DolibarrModules $this->numero = 240; $this->family = "technic"; - $this->module_position = 520; + $this->module_position = 72; // 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 = "Outils d'exports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 4735b0811a3..31b3fafff16 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -45,6 +45,7 @@ class modFckeditor extends DolibarrModules $this->numero = 2000; $this->family = "technic"; + $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 = "Editeur WYSIWYG"; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 63af9dc9064..8f3faad9bd1 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -44,7 +44,7 @@ class modImport extends DolibarrModules $this->numero = 250; $this->family = "technic"; - $this->module_position = 510; + $this->module_position = 70; // 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 = "Outils d'imports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 0b282584261..05e98d36454 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -44,6 +44,7 @@ class modLabel extends DolibarrModules $this->numero = 60; $this->family = "technic"; + $this->module_position = 80; // 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 etiquettes"; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 48ce8bc3bc0..7ae613edd49 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -52,9 +52,9 @@ class modMultiCurrency extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "financial"; + $this->family = "technic"; // Module position in the family - $this->module_position = 555; + $this->module_position = 40; // 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)); diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 81454a52222..7bdf5d1d641 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -194,8 +194,12 @@ class modStock extends DolibarrModules $this->import_convertvalue_array[$r]=array( 'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'), 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label') + ); + $this->import_examplevalues_array[$r]=array( + 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); - $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" + $this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after. + 'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);' ); } diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 8e019fabed8..e3b500b0e0d 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -46,7 +46,7 @@ class modWebsites extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; - $this->module_position = 20; + $this->module_position = 50; // 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 = "Enable the public website with CMS features"; diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index 4332c0b2e82..fa5b61744cf 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -145,6 +145,10 @@ class mod_syslog_sentry extends LogHandler implements LogHandlerInterface */ public function export($content) { + if (! $this->isActive()) { + return; + } + global $conf; $dsn = $conf->global->SYSLOG_SENTRY_DSN; $client = new Raven_Client( diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b7654746dc0..3a21cee968f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -32,7 +32,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) { $usemargins=1; } @@ -196,11 +196,17 @@ else { { $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } if (is_object($hookmanager) && ! empty($senderissupplier)) { $parameters=array('htmlname'=>'addproduct'); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } @@ -429,18 +435,12 @@ if (! empty($usemargins) && $user->rights->margins->creer) jQuery(document).ready(function() { global->DISPLAY_MARGIN_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_marginRate"); - }); $("input[name='np_marginRate']:first").blur(function(e) { return checkFreeLine(e, "np_marginRate"); }); global->DISPLAY_MARK_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_markRate"); - }); $("input[name='np_markRate']:first").blur(function(e) { return checkFreeLine(e, "np_markRate"); }); @@ -506,7 +506,7 @@ jQuery(document).ready(function() { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) + if (jQuery('#select_type').val() >= 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); @@ -645,7 +645,7 @@ jQuery(document).ready(function() { ?> /* To set focus */ - if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 7541cd90938..6d39cfc836b 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -329,9 +329,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARGIN_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_marginRate"); - }); /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); @@ -341,9 +338,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARK_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_markRate"); - }); /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); @@ -356,6 +350,7 @@ if (! empty($conf->margin->enabled)) /* If margin rate field empty, do nothing. */ /* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */ + /* TODO This function seems no more used */ function checkEditLine(e, npRate) { var buying_price = $("input[name='buying_price']:first"); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 87c7ae259d2..03be7e77d36 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -707,7 +707,7 @@ class ProductFournisseur extends Product { global $langs; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); return $out; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8bff36e159e..59bc805a120 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -472,6 +472,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2027,9 +2028,9 @@ elseif (! empty($object->id)) print '
'; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 1bdec7b9a8d..a797bc19fdc 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -243,7 +243,7 @@ if (! empty($conf->fournisseur->enabled)) /* * List of users allowed */ -$sql = "SELECT u.rowid, u.lastname, u.firstname"; +$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u,"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as rd"; @@ -276,6 +276,7 @@ if ($resql) $userstatic->id=$obj->rowid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; print $userstatic->getNomUrl(1); print ''; print "\n"; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d14dd97e6b3..64f459886ae 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -830,6 +830,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2053,9 +2054,9 @@ else print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } @@ -2350,7 +2351,11 @@ else // Delete if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { - print ''.$langs->trans('Delete').''; + if ($object->getSommePaiement()) { + print ''; + } else { + print ''.$langs->trans('Delete').''; + } } print ''; print '
'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index f82c8b62530..ad1ba8555a2 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -345,7 +345,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - dol_fiche_head(''); + dol_fiche_head(null); print ''; @@ -377,6 +377,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; dol_fiche_end(); + $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; @@ -527,10 +528,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $preselectedchoice=$addwarning?'no':'yes'; print '
'; - if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); + if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',price($totalpayment),$langs->trans("Currency".$conf->currency)); if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmSupplierPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + $text.='
'.$langs->trans('ConfirmSupplierPayment',price($multicurrency_totalpayment),$langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 9a4d58aa65f..254628b38fa 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -33,12 +33,18 @@ class Import var $array_import_code; var $array_import_label; var $array_import_tables; + var $array_import_tables_creator; var $array_import_fields; + var $array_import_fieldshidden; var $array_import_entities; var $array_import_regex; var $array_import_examplevalues; var $array_import_convertvalue; + var $array_import_run_sql_after; + var $error; + var $errors; + /** * Constructor @@ -137,7 +143,7 @@ class Import $this->array_import_label[$i]=$module->getImportDatasetLabel($r); // Array of tables to import (key=alias, value=tablename) $this->array_import_tables[$i]=$module->import_tables_array[$r]; - // Array of tables creator field to import (key=alias, value=creator field) + // Array of tables creator field to import (key=alias, value=creator field name) $this->array_import_tables_creator[$i]=(isset($module->import_tables_creator_array[$r])?$module->import_tables_creator_array[$r]:''); // Array of fields to import (key=field, value=label) $this->array_import_fields[$i]=$module->import_fields_array[$r]; @@ -151,6 +157,8 @@ class Import $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) $this->array_import_convertvalue[$i]=(isset($module->import_convertvalue_array[$r])?$module->import_convertvalue_array[$r]:''); + // Sql request to run after import + $this->array_import_run_sql_after[$i]=(isset($module->import_run_sql_after_array[$r])?$module->import_run_sql_after_array[$r]:''); // Module $this->array_import_module[$i]=$module; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 23d5a61415b..9b40c35ead6 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1142,6 +1142,7 @@ if ($step == 5 && $datatoimport) // Load source fields in input file $fieldssource=array(); $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs); + if ($result >= 0) { // Read first line @@ -1156,8 +1157,7 @@ if ($step == 5 && $datatoimport) $obj->import_close_file(); } - // TODO, remove this, since it only works for csv - $nboflines=dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport); + $nboflines=$obj->import_get_nb_of_lines($conf->import->dir_temp.'/'.$filetoimport); $param='&leftmenu=import&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport).'&nboflines='.$nboflines.'&separator='.urlencode($separator).'&enclosure='.urlencode($enclosure); $param2 = $param; // $param2 = $param without excludefirstline and endatlinenb @@ -1415,6 +1415,25 @@ if ($step == 5 && $datatoimport) print $langs->trans("ErrorFailedToOpenFile",$pathfile); } + $error=0; + + // Run the sql after import if defined + //var_dump($objimport->array_import_run_sql_after[0]); + if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) + { + $i=0; + foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport) + { + $i++; + $resqlafterimport=$db->query($sqlafterimport); + if (! $resqlafterimport) + { + $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); + $error++; + } + } + } + $db->rollback(); // We force rollback because this was just a simulation. // Show OK @@ -1740,8 +1759,31 @@ if ($step == 6 && $datatoimport) } if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors. - else $db->commit(); // We can commit if no errors. - + else + { + $error=0; + + // Run the sql after import if defined + //var_dump($objimport->array_import_run_sql_after[0]); + if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) + { + $i=0; + foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport) + { + $i++; + $resqlafterimport=$db->query($sqlafterimport); + if (! $resqlafterimport) + { + $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); + $error++; + } + } + } + + if (! $error) $db->commit(); // We can commit if no errors. + else $db->rollback(); + } + dol_fiche_end(); diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 403d74b13e9..6defe0e6004 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base { } $this->use_curl = $use_curl; preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); + $this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':'')); } /** diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 15de62fb3e8..70cb245c772 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -190,8 +190,7 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer NOT NULL DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; @@ -383,3 +382,4 @@ ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NU -- Delete old deprecated field ALTER TABLE llx_product_stock DROP COLUMN pmp; +ALTER TABLE llx_societe ADD COLUMN fk_shipping_method_id integer; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql index e6b90382dcd..333f5deab52 100644 --- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -22,6 +22,5 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 9822272e7c2..e5d6f722d2c 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -103,5 +103,6 @@ create table llx_societe webservices_key varchar(128), -- supplier webservice key fk_multicurrency integer, - multicurrency_code varchar(255) + multicurrency_code varchar(255), + fk_shipping_method_id integer )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3468dc43eee..b37083ca091 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -99,6 +99,7 @@ AntiVirusParamExample= Example for ClamWin: --database="C:\Program Files (x86)\C ComptaSetup=Accounting module setup UserSetup=User management setup MenuSetup=Menu management setup +MultiCurrencySetup=Multi-currency setup MenuLimits=Limits and accuracy MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 7b52f072eaf..189a8f25e38 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -5,7 +5,7 @@ PrinterUpdated=Printer %s updated PrinterDeleted=Printer %s deleted TestSentToPrinter=Test Sent To Printer %s ReceiptPrinter=Receipt printers -ReceiptPrinterDesc=Setup of printers +ReceiptPrinterDesc=Setup of receipt printers ReceiptPrinterTemplateDesc=Setup of Templates ReceiptPrinterTypeDesc=Description of Receipt Printer's type ReceiptPrinterProfileDesc=Description of Receipt Printer's Profile diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8652af27d82..697b2ab9ab9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1033,13 +1033,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; // JQuery print ''."\n"; // Tooltip print ''."\n"; // JNotify - /*if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || (defined('REQUIRE_JQUERY_FILEUPLOAD') && constant('REQUIRE_JQUERY_FILEUPLOAD'))) // jQuery fileupload - { - print ''."\n"; - }*/ if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) // jQuery datatables { - //print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -1131,11 +1126,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; print ''."\n"; print ''."\n"; - // jQuery Layout - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT')) - { - print ''."\n"; - } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { @@ -1374,60 +1364,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($conf->use_javascript_ajax) { - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print '' . "\n"; - } - // Raven.js for client-side Sentry logging support if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) { @@ -1448,8 +1384,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a */ print "\n".''."\n"; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - if (empty($conf->dol_hide_topmenu)) { print '
'; @@ -1579,11 +1513,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a //unset($form); } - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "
\n"; print '
'; print "\n\n"; - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; } @@ -1616,8 +1549,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('searchform','leftblock')); - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".''."\n".'
'."\n"; - else print "\n".''."\n".'
'."\n"; + print "\n".''."\n".'
'."\n"; print "\n"; @@ -1779,8 +1711,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra $reshook=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - else print '
'; // End div id="id-left" + print '
'; // End div id="id-left" } print "\n"; @@ -1800,7 +1731,6 @@ function main_area($title='') { global $conf, $langs; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; print "\n"; @@ -1944,7 +1874,6 @@ if (! function_exists("llxFooter")) print '
'."\n"; if (! empty($conf->dol_use_jmobile)) print '
'; // end data-role="page" - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; // End div id-right print "\n"; @@ -1953,7 +1882,7 @@ if (! function_exists("llxFooter")) printCommonFooter($zone); //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; // End div container + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'."\n"; // End div container if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 6687b9fcf59..84d7945ec0d 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -118,7 +118,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta $marge_tx_ret=''; $marque_tx_ret=''; - if ($fk_pa > 0) { + if ($fk_pa > 0 && empty($paht)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($fk_pa)) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index fd6da3816ea..b4baa550ce7 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -208,7 +208,7 @@ class MultiCurrency extends CommonObject $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -383,7 +383,7 @@ class MultiCurrency extends CommonObject * * @param double $rate rate value * - * @return bool false if KO, true if OK + * @return int -1 if KO, 1 if OK */ public function addRate($rate) { @@ -402,6 +402,40 @@ class MultiCurrency extends CommonObject } } + /** + * Try get label of code in llx_currency then add rate + * + * @param string $code currency code + * @param double $rate new rate + * + * @return int -1 if KO, 1 if OK, 2 if label found and OK + */ + function addRateFromDolibarr($code, $rate) + { + global $db, $user; + + $currency = new MultiCurrency($db); + $currency->code = $code; + $currency->name = $code; + + $sql = 'SELECT label FROM '.MAIN_DB_PREFIX.'c_currencies WHERE code_iso = "'.$db->escape($code).'"'; + $resql = $db->query($sql); + if ($resql && ($line = $db->fetch_object($resql))) + { + $currency->name = $line->label; + } + + if ($currency->create($user) > 0) + { + $currency->addRate($rate); + + if (!empty($line)) return 2; + else return 1; + } + + return -1; + } + /** * Update rate in database * @@ -471,7 +505,9 @@ class MultiCurrency extends CommonObject { $sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; + // FIXME Is this comptible with SQL ? $sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)'; + $sql.= " AND m.entity IN '".getEntity('multicurrency', 1)."'"; $resql = $db->query($sql); if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); else return array(0, 1); @@ -520,6 +556,66 @@ class MultiCurrency extends CommonObject return false; } + + /** + * With free account we can't set source then recalcul all rates to force another source + * + * @param stdClass $TRate Object containing all currencies rates + * @return -1 if KO, 0 if nothing, 1 if OK + */ + public static function recalculRates(&$TRate) + { + global $conf; + + if (!empty($conf->global->MULTICURRENCY_ALTERNATE_SOURCE)) + { + $alternate_source = 'USD'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE; + if (!empty($TRate->{$alternate_source})) + { + $coef = $TRate->USDUSD / $TRate->{$alternate_source}; + foreach ($TRate as $attr => &$rate) + { + $rate *= $coef; + } + + return 1; + } + + return -1; // Alternate souce not found + } + + return 0; // Nothing to do + } + + /** + * Sync rates from api + * + * @param array $response array of reponse from api to sync dolibarr rates + */ + public static function syncRates($response) + { + global $db,$conf; + + $TRate = $response->quotes; + $timestamp = $response->timestamp; + + if (self::recalculRates($TRate) >= 0) + { + foreach ($TRate as $currency_code => $rate) + { + $code = substr($currency_code, 3, 3); + $obj = new MultiCurrency($db); + if ($obj->fetch(null, $code) > 0) + { + $obj->updateRate($rate); + } + else + { + self::addRateFromDolibarr($code, $rate); + } + } + } + } } /** @@ -713,7 +809,7 @@ class CurrencyRate extends CommonObjectLine if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 9686c4683ae..f4b3f575eba 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -361,7 +361,7 @@ if ($id > 0 || ! empty($ref)) } print ''; - $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; print ($notdefined?'':($value['nb']> 1 ? $value['nb'].'x' : '').price($product_fourn->fourn_unitprice,'','',0,0,-1,$conf->currency)); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 84c72afc7a0..0a12d87fc2d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -407,8 +407,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/societe/soc.php b/htdocs/societe/soc.php index 866e53bcd6b..eedcd449c0d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1903,7 +1903,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/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 36d04f559e1..9101b6efda2 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -717,6 +717,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -841,6 +842,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1089,7 +1091,7 @@ if ($action == 'create') print '
'; // Reference - print ''; + print ''; // Third party print ''; @@ -1419,7 +1421,7 @@ if ($action == 'create') $linkback = '' . $langs->trans("BackToList") . ''; // Ref - print ''; @@ -1469,7 +1471,7 @@ if ($action == 'create') // Payment mode print ''; - print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . ''; + print '
' . $langs->trans('Ref') . ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; + print ''; print ''; @@ -1519,18 +1521,18 @@ if ($action == 'create') } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if ( empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; - print ''; - print ''; } @@ -1561,7 +1563,7 @@ if ($action == 'create') // Outstanding Bill print ''; @@ -1589,17 +1591,22 @@ if ($action == 'create') } // Other attributes - $cols = 3; + $cols = 2; + if (empty($conf->margin->enabled)) $cols++; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Amount HT - print ''; - print ''; - print ''; + print ''; + print ''; // Margin Infos if (! empty($conf->margin->enabled)) { - print ''; } @@ -1607,48 +1614,48 @@ if ($action == 'create') // Amount VAT print ''; - print ''; - print ''; + print ''; + print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { print ''; - print ''; - print ''; + print ''; + print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { print ''; - print ''; - print ''; + print ''; + print ''; } // Amount TTC print ''; - print ''; - print ''; + print ''; + print ''; if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT print ''; - print ''; + print ''; print ''; // Multicurrency Amount VAT print ''; - print ''; + print ''; print ''; // Multicurrency Amount TTC print ''; - print ''; + print ''; print ''; } // Statut - print ''; + print ''; print '
'; print $langs->trans('PaymentMode'); print '
'; + print ''; print ''; if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Currency','multicurrency_code'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -1540,18 +1542,18 @@ if ($action == 'create') // Multicurrency rate print '
'; + print ''; print ''; if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Rate','multicurrency_tx'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; + print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print '
'; print $langs->trans('OutstandingBill'); - print ''; + print ''; print price($soc->get_OutstandingBill()) . ' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + $rowspan=4; + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) $rowspan++; + if (!empty($conf->multicurrency->enabled)) $rowspan+=3; + print ''; $formmargin->displayMarginInfos($object); print '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '

'; diff --git a/htdocs/theme/eldy/img/menus/menu.png b/htdocs/theme/eldy/img/menus/menu.png new file mode 100644 index 00000000000..e8ef108b127 Binary files /dev/null and b/htdocs/theme/eldy/img/menus/menu.png differ diff --git a/htdocs/theme/eldy/img/menus_black/menu.png b/htdocs/theme/eldy/img/menus_black/menu.png new file mode 100644 index 00000000000..0b080a18715 Binary files /dev/null and b/htdocs/theme/eldy/img/menus_black/menu.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b772f741219..ce97dd1c14f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -646,7 +646,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'12':'6')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } @@ -683,7 +683,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } @@ -1021,6 +1021,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1040,7 +1044,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// 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','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; diff --git a/htdocs/theme/md/img/menu.png b/htdocs/theme/md/img/menu.png new file mode 100644 index 00000000000..e8ef108b127 Binary files /dev/null and b/htdocs/theme/md/img/menu.png differ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9644232d2c6..8997231230f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -699,7 +699,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'16':'4')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; @@ -737,7 +737,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; @@ -1072,6 +1072,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1091,7 +1095,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// 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','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; diff --git a/htdocs/user/index.php b/htdocs/user/index.php index f4c77644f1f..f7927cee665 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 @@ -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.")"; diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php new file mode 100644 index 00000000000..46a0bfe495a --- /dev/null +++ b/htdocs/websites/class/website.class.php @@ -0,0 +1,640 @@ + + * Copyright (C) 2014 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 websites/website.class.php + * \ingroup websites + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class Website + * + * Put here description of your class + * @see CommonObject + */ +class Website extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'website'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'website'; + + /** + * @var WebsiteLine[] Lines + */ + public $lines = array(); + + /** + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + return 1; + } + + /** + * 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->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // 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.= 'shortname,'; + $sql.= 'description,'; + $sql.= 'status,'; + $sql.= 'date_creation,'; + $sql.= 'date_modification'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; + $sql .= ' '.(! isset($this->shortname)?'NULL':"'".$this->db->escape($this->shortname)."'").','; + $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; + $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 .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $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, $ref = null) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if (null !== $ref) { + $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + } else { + $sql .= ' WHERE t.rowid = ' . $id; + } + + $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->entity = $obj->entity; + $this->shortname = $obj->shortname; + $this->description = $obj->description; + $this->status = $obj->status; + $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); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $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.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $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 + 1, $offset); + } + $this->lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new WebsiteLine(); + + $line->id = $obj->rowid; + + $line->entity = $obj->entity; + $line->shortname = $obj->shortname; + $line->description = $obj->description; + $line->status = $obj->status; + $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->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $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->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $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 .= ' shortname = '.(isset($this->shortname)?"'".$this->db->escape($this->shortname)."'":"null").','; + $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; + $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; + $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(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $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 (!$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__ . ' ' . join(',', $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 Website($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__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param integer $notooltip 1=Disable tooltip + * @param int $maxlen Max length of visible user name + * @param string $morecss Add more css on link + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + { + global $langs, $conf, $db; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("MyModule") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $link = 'ref . $linkend; + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un status donne + * + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->entity = ''; + $this->shortname = ''; + $this->description = ''; + $this->status = ''; + $this->date_creation = ''; + $this->date_modification = ''; + $this->tms = ''; + + + } + +} + +/** + * Class WebsiteLine + */ +class WebsiteLine +{ + /** + * @var int ID + */ + public $id; + /** + * @var mixed Sample line property 1 + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + * @var mixed Sample line property 2 + */ + +} diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 7c52b440f44..a975bac297a 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -21,8 +21,49 @@ * \brief Page to setup the module Website */ + +/** + * Show HTML header HTML + BODY + Top menu + left menu + DIV + * + * @param string $head Optionnal head lines + * @param string $title HTML title + * @param string $help_url Url links to help page + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * For other external page: http://server/url + * @param string $target Target to use on links + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @return void + */ +function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') +{ + global $conf; + + // html header + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + + // top menu and left menu area + if (empty($conf->dol_hide_topmenu)) + { + top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); + } + if (empty($conf->dol_hide_leftmenu)) + { + left_menu('', $help_url, '', '', 1, $title, 1); + } + + // main area + //main_area($title); +} + + + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; $langs->load("admin"); $langs->load("other"); @@ -36,7 +77,7 @@ $conf->dol_hide_leftmenu = 1; $website='website1'; - +$object=new Website($db); /* @@ -75,12 +116,21 @@ $form = new Form($db); $help_url=''; -llxHeader('',$langs->trans("WebsiteSetup"),$help_url); +llxHeader('', $langs->trans("WebsiteSetup"), $help_url); +$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"'; -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("WebsiteSetup"),$linkback,'title_setup'); +print '
'; +// Loop on each sites + +$tmp = $object->fetchAll(); +foreach($object->lines as $websitearray) +{ + var_dump($websitearray); +} + +print '
'; $head = array(); @@ -95,10 +145,6 @@ if ($_SESSION['website_mode'] == 'edit') print ''; print ''; - dol_fiche_head($head, 'general', $langs->trans("Page").': '.$langs->trans("Home"), 0, 'globe'); - - print load_fiche_titre($langs->trans("SEO"),'',''); - print ''; print ''; print ''; @@ -152,8 +198,6 @@ if ($_SESSION['website_mode'] == 'edit') $doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); $doleditor->Create(); - dol_fiche_end(); - print '
'; print '';
'.$langs->trans("Description").'