diff --git a/ChangeLog b/ChangeLog index 402bb45423b..f257c8a3c7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,17 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 8.0.0 compared to 8.0.0 ***** + +For Users: +NEW: Stable module: Website +NEW: Stable module: WebDAV +NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making + Android application like DoliDroid able to provide native features for multicompany module + + + ***** ChangeLog for 8.0.0 compared to 7.0.0 ***** For Users: @@ -10,11 +21,11 @@ NEW: Experimental module: WebDAV NEW: Accept anonymous events (no user assigned) NEW: Accountancy - Add import on general ledger NEW: Accountancy - Show journal name on journal page and hide button draft export (Add an option in admin) -NEW: Can create event from record card of a company and member -NEW: Add a button to create Stripe customer from the Payment mode tab +NEW: Can create event from record card of a company and/or member +NEW: Add a button to create Stripe customer from the customer Payment mode tab NEW: Add accounting account number on product tooltip -NEW: add any predefined mail content -NEW: Add arrows to navigate into containers in website module +NEW: Add any predefined mail content +NEW: Add arrows to navigate into containers in experimental website module NEW: Add a tab to specify accountant/auditor of the company NEW: Add Date delivery and Availability on Propals List NEW: Add date in goods reception supplier order table diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index f65cefd7f94..2eedcda8760 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -295,6 +295,9 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0; if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0; if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0; + // admin.lang + if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0; + if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0; // boxes.lang if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0; if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index f14a3e7f761..53717968320 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -29,7 +29,11 @@ class AccountancySystem { var $db; - var $error; + /** + * @var string Error code (or message) + */ + public $error=''; + var $rowid; var $fk_pcg_version; var $pcg_type; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 257c2af0111..d8ad61dc7f1 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -46,8 +46,18 @@ class AccountingAccount extends CommonObject public $restrictiononfksoc = 1; var $db; - var $error; - var $errors; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $id; var $rowid; var $datec; // Creation date diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index f49d1cecb99..d23334ecef5 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -41,10 +41,16 @@ abstract class ActionsAdherentCardCommon var $tpl = array(); //! Object container var $object; - //! Error string - var $error; - //! Error array - var $errors=array(); + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); /** diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 1443be3c104..b5b33be77aa 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -313,7 +313,9 @@ if ($mode == 'desc') { $textexternal.='
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule",$dirofmodule); if ($objMod->editor_name != 'dolibarr') $textexternal.='
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name); - if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.''; + $editor_url = $objMod->editor_url; + if (! preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; + if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.''; $text.=$textexternal; $text.='
'; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index dae5fb70617..e63d09afcb7 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent @@ -927,6 +927,15 @@ if ($action == 'create') if ($id > 0) { $result1=$object->fetch($id); + if ($result1 <= 0) + { + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); + + llxFooter(); + exit; + } + $result2=$object->fetch_thirdparty(); $result2=$object->fetch_projet(); $result3=$object->fetch_contact(); @@ -957,7 +966,7 @@ if ($id > 0) $object->note = GETPOST("note",'none'); } - if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) + if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { dol_print_error($db,$object->error); exit; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 65b19c55387..f162d228182 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -621,7 +621,7 @@ class ActionComm extends CommonObject $this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; + $this->elementid = $obj->elementid; $this->elementtype = $obj->elementtype; $this->fetchResources(); diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index d8496a9a4ff..22b7b6fa26c 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -28,7 +28,11 @@ */ class CActionComm { - var $error; + /** + * @var string Error code (or message) + */ + public $error=''; + var $db; var $id; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 50d9faf0637..2b0e31930c2 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -30,8 +30,17 @@ class AdvanceTargetingMailing extends CommonObject { var $db; //!< To store db handler - var $error; //!< To return error code (or message) - var $errors = array(); //!< To return several error codes (or messages) + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $element='advtargetemailing'; //!< Id that identify managed objects var $table_element='advtargetemailing'; //!< Name of table without prefix where object is stored diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 7408bb27d37..9fb00e8dc73 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -27,7 +27,10 @@ class FormAdvTargetEmailing extends Form { var $db; - var $error; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Constructor diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e49fe43e2c9..848ac60d822 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1335,13 +1335,12 @@ class Propal extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; - $sql.= " WHERE p.fk_statut = c.id"; if ($ref) { - $sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid - $sql.= " AND p.ref='".$ref."'"; + $sql.= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid + $sql.= " AND p.ref='".$this->db->escape($ref)."'"; } - else $sql.= " AND p.rowid=".$rowid; + else $sql.= " WHERE p.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -3145,7 +3144,7 @@ class Propal extends CommonObject $clause = " WHERE"; - $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin"; + $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -3189,6 +3188,8 @@ class Propal extends CommonObject while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; + $response->total+=$obj->total_ht; + if ($mode == 'opened') { $datelimit = $this->db->jdate($obj->datefin); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 941c061eea1..8ee90b6d583 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3243,7 +3243,7 @@ class Commande extends CommonOrder $clause = " WHERE"; - $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut"; + $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -3270,6 +3270,7 @@ class Commande extends CommonOrder while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; + $response->total+= $obj->total_ht; $generic_commande->statut = $obj->fk_statut; $generic_commande->date_commande = $this->db->jdate($obj->date_commande); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 6c2ad4ef302..ff5a3b2fffd 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1423,14 +1423,14 @@ if ($resql) if (! empty($arrayfields['b.conciliated']['checked'])) { - print ''; + print ''; print $objp->conciliated?$langs->trans("Yes"):$langs->trans("No"); print ''; if (! $i) $totalarray['nbfield']++; } // Action edit/delete - print ''; + print ''; // Transaction reconciliated or edit link if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b09c0435bcd..af3597de447 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3726,7 +3726,7 @@ class Facture extends CommonInvoice $clause = " WHERE"; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -3759,6 +3759,7 @@ class Facture extends CommonInvoice $generic_facture->statut = $obj->fk_statut; $response->nbtodo++; + $response->total += $obj->total; if ($generic_facture->hasDelay()) { $response->nbtodolate++; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3697a61672b..7e9524ad9af 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -30,7 +30,12 @@ class PaymentTerm // extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + //public $element='c_payment_term'; //!< Id that identify managed objects //public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored var $context =array(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6ae531db133..f9d8bd1b250 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -923,6 +923,9 @@ if ($resql) $facturestatic->id=$obj->id; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; + $facturestatic->total_ht=$obj->total_ht; + $facturestatic->total_tva=$obj->total_vat; + $facturestatic->total_ttc=$obj->total_ttc; $facturestatic->statut=$obj->fk_statut; $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $facturestatic->note_public=$obj->note_public; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index ebaef08c7b5..ea43c270b5f 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -722,7 +722,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc"; + $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; $resql = $db->query($sql); if ( $resql ) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index ba96c865d1a..c8ef79bc72e 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -39,8 +39,12 @@ abstract class ActionsContactCardCommon var $object; //! Error string var $error; - //! Error array - var $errors=array(); + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); /** diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 1ce48a7371d..114490fa373 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -197,7 +197,7 @@ $now=dol_now(); $form=new Form($db); $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; -$sql.= " s.rowid as socid, s.nom as name,"; +$sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; $sql.= " cd.rowid, cd.description, cd.statut,"; $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -540,6 +540,11 @@ while ($i < min($num,$limit)) $contractstatic->id=$obj->cid; $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->email=$obj->email; + $companystatic->client=$obj->client; + $companystatic->fournisseur=$obj->fournisseur; print ''; @@ -555,7 +560,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.description']['checked'])) { print ''; - if ($obj->pid) + if ($obj->pid > 0) { $productstatic->id=$obj->pid; $productstatic->type=$obj->ptype; @@ -625,9 +630,6 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=1; print $companystatic->getNomUrl(1,'customer',28); print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 62b61e531bf..302ad161241 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014 Frederic France + * Copyright (C) 2014-2018 Frederic France * * 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 @@ -28,7 +28,7 @@ // Filename to print must be provided into 'file' parameter // Print file -if ($action == 'print_file' and $user->rights->printing->read) +if ($action == 'print_file' && $user->rights->printing->read) { $langs->load("printing"); require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index b5f4f0e5539..ad31c60e664 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -32,7 +32,12 @@ class AntiVir { var $error; - var $errors; + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array ();; + var $output; var $db; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index d9c496add4f..e5b984a255d 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -30,7 +30,11 @@ class Canvas { var $db; var $error; - var $errors=array(); + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); var $actiontype; diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 7964510c91c..96d8ab69826 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -34,7 +34,12 @@ class Ccountry // extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + //var $element='ccountry'; //!< Id that identify managed objects //var $table_element='ccountry'; //!< Name of table without prefix where object is stored diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index ae2adde87d4..592962edf65 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -34,7 +34,12 @@ class Cstate // extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + //var $element='cstate'; //!< Id that identify managed objects //var $table_element='cstate'; //!< Name of table without prefix where object is stored diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index b3bb750bd80..9b36ec470b4 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -29,7 +29,12 @@ class Ctypent // extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index c09aaad16e8..6138463d744 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -110,7 +110,11 @@ class dolReceiptPrinter extends Escpos var $printer; var $template; var $error; - var $errors; + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 439e31caae1..11d29b7a7ad 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -31,7 +31,11 @@ class HookManager { var $db; var $error; - var $errors=array(); + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); // Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...) var $contextarray=array(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7c457accadf..117ec484c15 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -778,7 +778,8 @@ class FormFile $out.= ''; if ($delallowed) { - $out.= 'numoffiles++; } - // Loop on each file found + // Loop on each link found if (is_array($link_list)) { $colspan=2; @@ -1304,8 +1305,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - - print ''.img_delete().''; + print ''.img_delete().''; } print ""; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 655969d73f6..e6325df8836 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -33,7 +33,11 @@ class Interfaces { var $db; var $dir; // Directory with all core and external triggers files - var $errors = array(); // Array for errors + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); /** * Constructor diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 1cd676fe70b..c9d04b93dde 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -33,7 +33,11 @@ class Notify var $id; var $db; var $error; - var $errors=array(); + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); var $author; var $ref; diff --git a/htdocs/core/class/workboardresponse.class.php b/htdocs/core/class/workboardresponse.class.php index 13de74281ff..62d84e11186 100644 --- a/htdocs/core/class/workboardresponse.class.php +++ b/htdocs/core/class/workboardresponse.class.php @@ -1,6 +1,7 @@ + * Copyright (C) 2018 Charlene Benke * * 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 @@ -66,4 +67,10 @@ class WorkboardResponse */ public $nbtodolate = 0; -} \ No newline at end of file + /** + * total price of items + * @var int + */ + public $total = 0; + +} diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 0e7203ba748..884dbaa120c 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -108,27 +108,36 @@ function versiondolibarrarray() /** - * Launch a sql file. Function used by: + * Launch a sql file. Function is used by: * - Migrate process (dolibarr-xyz-abc.sql) * - Loading sql menus (auguria) * - Running specific Sql by a module init + * - Loading sql file of website import package * Install process however does not use it. - * Note that Sql files must have all comments at start of line. + * Note that Sql files must have all comments at start of line. Also this function take ';' as the char to detect end of sql request * - * @param string $sqlfile Full path to sql file - * @param int $silent 1=Do not output anything, 0=Output line for update page - * @param int $entity Entity targeted for multicompany module - * @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions). - * @param string $handler Handler targeted for menu - * @param string $okerror Family of errors we accept ('default', 'none') - * @return int <=0 if KO, >0 if OK + * @param string $sqlfile Full path to sql file + * @param int $silent 1=Do not output anything, 0=Output line for update page + * @param int $entity Entity targeted for multicompany module + * @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions). + * @param string $handler Handler targeted for menu (replace __HANDLER__ with this value) + * @param string $okerror Family of errors we accept ('default', 'none') + * @param int $linelengthlimit Limit for length of each line (Use 0 if unknown, may be faster if defined) + * @param int $nocommentremoval Do no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0) + * @return int <=0 if KO, >0 if OK */ -function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$okerror='default') +function run_sql($sqlfile, $silent=1, $entity='', $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0) { global $db, $conf, $langs, $user; dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler." okerror=".$okerror, LOG_DEBUG); + if (! is_numeric($linelengthlimit)) + { + dol_syslog("Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR); + return -1; + } + $ok=0; $error=0; $i=0; @@ -143,7 +152,9 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker { while (! feof($fp)) { - $buf = fgets($fp, 32768); + // Warning fgets with second parameter that is null or 0 hang. + if ($linelengthlimit > 0) $buf = fgets($fp, $linelengthlimit); + else $buf = fgets($fp); // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i',$buf,$reg)) @@ -191,13 +202,13 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker } // Add line buf to buffer if not a comment - if (! preg_match('/^\s*--/',$buf)) + if ($nocommentremoval || ! preg_match('/^\s*--/',$buf)) { - $buf=preg_replace('/([,;ERLT\)])\s*--.*$/i','\1',$buf); //remove comment from a line that not start with -- before add it to the buffer + if (empty($nocommentremoval)) $buf=preg_replace('/([,;ERLT\)])\s*--.*$/i','\1',$buf); //remove comment from a line that not start with -- before add it to the buffer $buffer .= trim($buf); } - // print $buf.'
'; + //print $buf.'
';exit; if (preg_match('/;/',$buffer)) // If string contains ';', it's end of a request string, we save it in arraysql. { @@ -229,7 +240,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker if (! isset($listofmaxrowid[$table])) { //var_dump($db); - $sqlgetrowid='SELECT MAX(rowid) as max from '.$table; + $sqlgetrowid='SELECT MAX(rowid) as max from '.preg_replace('/^llx_/', MAIN_DB_PREFIX, $table); $resql=$db->query($sqlgetrowid); if ($resql) { @@ -246,9 +257,10 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker break; } } + // Replace __+MAX_llx_table__ with +999 $from='__+MAX_'.$table.'__'; $to='+'.$listofmaxrowid[$table]; - $newsql=str_replace($from,$to,$newsql); + $newsql=str_replace($from, $to, $newsql); dol_syslog('Admin.lib::run_sql New Request '.($i+1).' (replacing '.$from.' to '.$to.')', LOG_DEBUG); $arraysql[$i]=$newsql; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 15e8c003417..a7001d357b8 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -574,7 +574,7 @@ function dol_filemtime($pathoffile) * @param array $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' - * @param int $indexdatabase Index new file into database. + * @param int $indexdatabase 1=index new file into database. * @return int <0 if error, 0 if nothing done (dest file already exists), >0 if OK * @see dol_copy dolReplaceRegExInFile */ @@ -611,7 +611,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, dol_delete_file($tmpdestfile); // Create $newpathoftmpdestfile from $newpathofsrcfile - $content=file_get_contents($newpathofsrcfile, 'r'); + $content = file_get_contents($newpathofsrcfile, 'r'); $content = make_substitutions($content, $arrayreplacement, null); @@ -1509,7 +1509,7 @@ function dol_init_file_process($pathtoscan='', $trackid='') * * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) * @param int $allowoverwrite 1=Allow overwrite existing file - * @param int $donotupdatesession 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. + * @param int $donotupdatesession 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. -1=Do not update SESSION neither db. * @param string $varfiles _FILES var name * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $link Link to add (to add a link instead of a file) @@ -1591,7 +1591,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio } // Update table of files - if ($donotupdatesession) + if ($donotupdatesession == 1) { $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', 0); if ($result < 0) @@ -1656,7 +1656,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio * All information used are in db, conf, langs, user and _FILES. * * @param int $filenb File nb to delete - * @param int $donotupdatesession 1=Do not edit _SESSION variable + * @param int $donotupdatesession -1 or 1 = Do not update _SESSION variable * @param int $donotdeletefile 1=Do not delete physically file * @param string $trackid Track id (used to prefix name of session vars to avoid conflict) * @return void diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 226619b90e1..92cab65b7b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3125,8 +3125,8 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo * @param boolean|int $pictoisfullpath If true or 1, image path is a full path * @param int $srconly Return only content of the src attribute of img. * @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip. - * @param string $alt Force alt for bind peoplae - * @param string $morecss Add more class css on img tag (For example 'myclascss') + * @param string $alt Force alt for bind people + * @param string $morecss Add more class css on img tag (For example 'myclascss'). Work only if $moreatt is empty. * @return string Return img tag * @see #img_object, #img_picto_common */ @@ -3282,7 +3282,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //$title=$tmparray[0]; //$alt=empty($tmparray[1])?'':$tmparray[1]; $title = $titlealt; - return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup + return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index c50661de831..5f207999cd8 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -48,6 +48,7 @@ function propal_prepare_head($object) || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); + $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index 2971b6f59ee..d4c55ce6bdc 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -28,7 +28,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleAction extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index b0a121d7dc5..703f61cda10 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -31,7 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleBankAccountDoc extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index a76fa073118..17a98d9cd77 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -33,7 +33,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to inc class modPhpbarcode extends ModeleBarCode { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' - var $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index 9d064ec267c..fcf01131f46 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -32,7 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to inc class modTcpdfbarcode extends ModeleBarCode { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' - var $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; + var $is2d = false; /** diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 4720ffb1341..279a5f0abf8 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -29,7 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ abstract class ModeleBarCode { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -50,7 +53,10 @@ abstract class ModeleBarCode */ abstract class ModeleNumRefBarCode { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return default description of numbering model * diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 680357ce9bb..8906bdcc14f 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -31,7 +31,10 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='CHK'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $name='Mint'; diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index 9ba039a6487..f4dad0b4a26 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -36,7 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requ */ abstract class ModeleNumRefChequeReceipts { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not @@ -119,7 +122,10 @@ abstract class ModeleNumRefChequeReceipts */ abstract class ModeleChequeReceipts extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index 9941811006b..69c25f73d68 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -31,7 +31,10 @@ class mod_commande_marbre extends ModeleNumRefCommandes { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='CO'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Marbre'; diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index aa6da728f56..1e58104c9ca 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -39,7 +39,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; */ abstract class ModelePDFCommandes extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules @@ -71,7 +74,10 @@ abstract class ModelePDFCommandes extends CommonDocGenerator abstract class ModeleNumRefCommandes { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 5dcb8a72baa..1f85e4d57fc 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -30,7 +30,10 @@ class mod_contract_serpis extends ModelNumRefContracts { var $version='dolibarr'; var $prefix='CT'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Serpis'; var $code_auto=1; diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 47a882b7b56..f0af2e7f78a 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -37,7 +37,10 @@ */ abstract class ModelePDFContract extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -67,7 +70,10 @@ abstract class ModelePDFContract extends CommonDocGenerator */ class ModelNumRefContracts { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 4949cce94e1..f2cba175a60 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -34,7 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; */ abstract class ModeleDon extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules @@ -63,7 +66,10 @@ abstract class ModeleDon extends CommonDocGenerator */ abstract class ModeleNumRefDons { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 826ba6665c4..e9e0adc7e39 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -30,7 +30,10 @@ class mod_expedition_safor extends ModelNumRefExpedition { var $version='dolibarr'; var $prefix='SH'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Safor'; diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index f46fa33c5f1..0fc12428d62 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -36,7 +36,10 @@ */ abstract class ModelePdfExpedition extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -66,7 +69,10 @@ abstract class ModelePdfExpedition extends CommonDocGenerator */ abstract class ModelNumRefExpedition { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return if a model can be used or not * diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index c6153d422eb..b1e01d40bb9 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -30,7 +30,10 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='ER'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Jade'; diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index e97766b38f6..f60899eee0a 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -23,7 +23,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleExpenseReport extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -73,7 +76,10 @@ function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $ abstract class ModeleNumRefExpenseReport { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 5d7e0ecac84..c154420f554 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -30,7 +30,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance propreties loaded by liste_modeles { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $driverlabel=array(); var $driverversion=array(); diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 831dce5d3e4..c6bba0a6232 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -35,7 +35,10 @@ class mod_facture_mars extends ModeleNumRefFactures var $prefixreplacement='FR'; var $prefixdeposit='AC'; var $prefixcreditnote='AV'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 174d8314784..53ae127b734 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -33,7 +33,10 @@ class mod_facture_terre extends ModeleNumRefFactures var $prefixinvoice='FA'; var $prefixcreditnote='AV'; var $prefixdeposit='AC'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index b5d9a2397cc..47b4506bdb4 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -37,7 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requ */ abstract class ModelePDFFactures extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules @@ -65,7 +68,10 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ abstract class ModeleNumRefFactures { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 7e60a6aed4b..2461d8a074d 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -32,7 +32,10 @@ class mod_pacific extends ModeleNumRefFicheinter { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='FI'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom = 'pacific'; diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 8bcb2990bdb..619f2b888bc 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -34,7 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFFicheinter extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -64,7 +67,10 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator */ abstract class ModeleNumRefFicheinter { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 3b77230f77f..9031c31036d 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -31,7 +31,10 @@ class mod_holiday_madonna extends ModelNumRefHolidays { var $version='dolibarr'; var $prefix='HL'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Madonna'; var $code_auto=1; diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 901a7531cbe..6449f48d96f 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -38,7 +38,10 @@ */ abstract class ModelePDFHoliday extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -68,7 +71,10 @@ abstract class ModelePDFHoliday extends CommonDocGenerator */ class ModelNumRefHolidays { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index f6d94e08e97..23034c436bf 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -36,8 +36,16 @@ class ImportCsv extends ModeleImports var $db; var $datatoimport; - var $error=''; - var $errors=array(); + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); var $id; // Id of driver var $label; // Label of driver diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 545fb8d4466..0b2af5fe021 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -36,8 +36,16 @@ class ImportXlsx extends ModeleImports var $db; var $datatoimport; - var $error=''; - var $errors=array(); + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); var $id; // Id of driver var $label; // Label of driver diff --git a/htdocs/core/modules/livraison/modules_livraison.php b/htdocs/core/modules/livraison/modules_livraison.php index a433f42930d..13d83939afb 100644 --- a/htdocs/core/modules/livraison/modules_livraison.php +++ b/htdocs/core/modules/livraison/modules_livraison.php @@ -36,7 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules @@ -67,7 +70,10 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator */ abstract class ModeleNumRefDeliveryOrder { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index f7ef8b94590..4e3e1a2dac4 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -34,7 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ModelePDFCards { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index 77c3f8feef7..f6c34f030a0 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -68,7 +68,7 @@ class modDav extends DolibarrModules $this->descriptionlong = "davDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index f684985917a..7d0b0540ed2 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -51,7 +51,7 @@ class modWebsite extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable to build and serve public web sites with CMS features"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index 8fc05b6cdd8..5111d0fc9be 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -31,7 +31,10 @@ class mod_payment_cicada extends ModeleNumRefPayments { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='PAY'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Cicada'; diff --git a/htdocs/core/modules/payment/modules_payment.php b/htdocs/core/modules/payment/modules_payment.php index c9023a9fc65..d9cf9b1260f 100644 --- a/htdocs/core/modules/payment/modules_payment.php +++ b/htdocs/core/modules/payment/modules_payment.php @@ -23,7 +23,10 @@ abstract class ModeleNumRefPayments { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7cda95174c2..8e4eafeb7b8 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -43,7 +43,12 @@ class printing_printgcp extends PrintingDriver var $google_id = ''; var $google_secret = ''; var $error; - var $errors = array(); + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $db; private $OAUTH_SERVICENAME_GOOGLE = 'Google'; diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 94d14426b55..168c411ec29 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -41,7 +41,12 @@ class printing_printipp extends PrintingDriver var $user; var $password; var $error; - var $errors = array(); + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $db; diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index bac32ec45d2..047d7aeed76 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -34,7 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ModelePDFLabels { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 83fc444f258..3b0324a8460 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -33,7 +33,10 @@ */ abstract class ModelePDFProduct extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -58,7 +61,10 @@ abstract class ModelePDFProduct extends CommonDocGenerator abstract class ModeleProductCode { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Renvoi la description par defaut du modele de numerotation * diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php index 94818d17531..df94c98871f 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -38,7 +38,10 @@ */ abstract class ModelePDFProductBatch extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index d936c01139f..62898fc40a3 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -160,6 +160,7 @@ class doc_generic_project_odt extends ModelePDFProjects 'task_description'=>$task->description, 'task_fk_parent'=>$task->fk_parent, 'task_duration'=>$task->duration, + 'task_duration_hour'=>convertSecondToTime($task->duration,'all'), 'task_progress'=>$task->progress, 'task_public'=>$task->public, 'task_date_start'=>dol_print_date($task->date_start,'day'), @@ -317,7 +318,10 @@ class doc_generic_project_odt extends ModelePDFProjects 'tasktime_fk_user'=>$tasktime['fk_user'], 'tasktime_user_name'=>$tasktime['name'], 'tasktime_user_first'=>$tasktime['firstname'], - 'tasktime_fullcivname'=>$tasktime['fullcivname'] + 'tasktime_fullcivname'=>$tasktime['fullcivname'], + 'tasktime_amountht'=>$tasktime['amountht'], + 'tasktime_amountttc'=>$tasktime['amountttc'], + 'tasktime_thm'=>$tasktime['thm'], ); } @@ -698,7 +702,7 @@ class doc_generic_project_odt extends ModelePDFProjects //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname"; + $sql.= ", u.lastname, u.firstname, t.thm"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$task->id; @@ -712,6 +716,35 @@ class doc_generic_project_odt extends ModelePDFProjects $i = 0; $tasks = array(); $listlinestasktime = $listlines->__get('taskstimes'); + if (empty($num)) { + $row['rowid']=''; + $row['task_date']=''; + $row['task_duration']=''; + $row['$tasktime']=''; + $row['note']=''; + $row['fk_user']=''; + $row['name']=''; + $row['firstname']=''; + $row['fullcivname']=''; + $row['amountht']=''; + $row['amountttc']=''; + $row['thm']=''; + $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); + foreach($tmparray as $key => $val) + { + try + { + $listlinestasktime->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlinestasktime->merge(); + } while ($i < $num) { $row = $this->db->fetch_array($resql); @@ -723,6 +756,16 @@ class doc_generic_project_odt extends ModelePDFProjects $row['fullcivname']=''; } + if (!empty($row['thm'])) { + $row['amountht']=($row['task_duration'] / 3600) * $row['thm']; + $defaultvat = get_default_tva($mysoc, $mysoc); + $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');; + } else { + $row['amountht']=0; + $row['amountttc']=0; + $row['thm']=0; + } + $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); foreach($tmparray as $key => $val) @@ -884,60 +927,114 @@ class doc_generic_project_odt extends ModelePDFProjects //List of referent - $listofreferent=array( - 'propal'=>array( - 'title'=>"ListProposalsAssociatedProject", - 'class'=>'Propal', - 'table'=>'propal', - 'test'=>$conf->propal->enabled && $user->rights->propale->lire), - 'order'=>array( - 'title'=>"ListOrdersAssociatedProject", - 'class'=>'Commande', - 'table'=>'commande', - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), - 'invoice'=>array( - 'title'=>"ListInvoicesAssociatedProject", - 'class'=>'Facture', - 'table'=>'facture', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), - 'invoice_predefined'=>array( - 'title'=>"ListPredefinedInvoicesAssociatedProject", - 'class'=>'FactureRec', - 'table'=>'facture_rec', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), - 'order_supplier'=>array( - 'title'=>"ListSupplierOrdersAssociatedProject", - 'table'=>'commande_fournisseur', - 'class'=>'CommandeFournisseur', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), - 'invoice_supplier'=>array( - 'title'=>"ListSupplierInvoicesAssociatedProject", - 'table'=>'facture_fourn', - 'class'=>'FactureFournisseur', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), - 'contract'=>array( - 'title'=>"ListContractAssociatedProject", - 'class'=>'Contrat', - 'table'=>'contrat', - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), - 'intervention'=>array( - 'title'=>"ListFichinterAssociatedProject", - 'class'=>'Fichinter', - 'table'=>'fichinter', - 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), - 'trip'=>array( - 'title'=>"ListTripAssociatedProject", - 'class'=>'Deplacement', - 'table'=>'deplacement', - 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), - 'agenda'=>array( - 'title'=>"ListActionsAssociatedProject", - 'class'=>'ActionComm', - 'table'=>'actioncomm', - 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) + $listofreferent = array( + 'propal' => array( + 'title' => "ListProposalsAssociatedProject", + 'class' => 'Propal', + 'table' => 'propal', + 'test' => $conf->propal->enabled && $user->rights->propale->lire + ), + 'order' => array( + 'title' => "ListOrdersAssociatedProject", + 'class' => 'Commande', + 'table' => 'commande', + 'test' => $conf->commande->enabled && $user->rights->commande->lire + ), + 'invoice' => array( + 'title' => "ListInvoicesAssociatedProject", + 'class' => 'Facture', + 'table' => 'facture', + 'test' => $conf->facture->enabled && $user->rights->facture->lire + ), + 'invoice_predefined' => array( + 'title' => "ListPredefinedInvoicesAssociatedProject", + 'class' => 'FactureRec', + 'table' => 'facture_rec', + 'test' => $conf->facture->enabled && $user->rights->facture->lire + ), + 'proposal_supplier' => array( + 'title' => "ListSupplierProposalsAssociatedProject", + 'class' => 'SupplierProposal', + 'table' => 'supplier_proposal', + 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire + ), + 'order_supplier' => array( + 'title' => "ListSupplierOrdersAssociatedProject", + 'table' => 'commande_fournisseur', + 'class' => 'CommandeFournisseur', + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire + ), + 'invoice_supplier' => array( + 'title' => "ListSupplierInvoicesAssociatedProject", + 'table' => 'facture_fourn', + 'class' => 'FactureFournisseur', + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire + ), + 'contract' => array( + 'title' => "ListContractAssociatedProject", + 'class' => 'Contrat', + 'table' => 'contrat', + 'test' => $conf->contrat->enabled && $user->rights->contrat->lire + ), + 'intervention' => array( + 'title' => "ListFichinterAssociatedProject", + 'class' => 'Fichinter', + 'table' => 'fichinter', + 'disableamount' => 1, + 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire + ), + 'shipping' => array( + 'title' => "ListShippingAssociatedProject", + 'class' => 'Expedition', + 'table' => 'expedition', + 'disableamount' => 1, + 'test' => $conf->expedition->enabled && $user->rights->expedition->lire + ), + 'trip' => array( + 'title' => "ListTripAssociatedProject", + 'class' => 'Deplacement', + 'table' => 'deplacement', + 'disableamount' => 1, + 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire + ), + 'expensereport' => array( + 'title' => "ListExpenseReportsAssociatedProject", + 'class' => 'ExpenseReportLine', + 'table' => 'expensereport_det', + 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire + ), + 'donation' => array( + 'title' => "ListDonationsAssociatedProject", + 'class' => 'Don', + 'table' => 'don', + 'test' => $conf->don->enabled && $user->rights->don->lire + ), + 'loan' => array( + 'title' => "ListLoanAssociatedProject", + 'class' => 'Loan', + 'table' => 'loan', + 'test' => $conf->loan->enabled && $user->rights->loan->read + ), + 'chargesociales' => array( + 'title' => "ListSocialContributionAssociatedProject", + 'class' => 'ChargeSociales', + 'table' => 'chargesociales', + 'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id, + 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire + ), + 'stock_mouvement' => array( + 'title' => "ListMouvementStockProject", + 'class' => 'MouvementStock', + 'table' => 'stock_mouvement', + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) + ), + 'agenda' => array( + 'title' => "ListActionsAssociatedProject", + 'class' => 'ActionComm', + 'table' => 'actioncomm', + 'disableamount' => 1, + 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire + ) ); //Insert reference diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 05256a3e61f..ccf4de57d5a 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -33,7 +33,10 @@ class mod_project_simple extends ModeleNumRefProjects { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='PJ'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom = "Simple"; var $name = "Simple"; diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 5f7ef3d5756..898cb202744 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -31,7 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFProjects extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -62,7 +65,10 @@ abstract class ModelePDFProjects extends CommonDocGenerator */ abstract class ModeleNumRefProjects { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 1a0aa3e3445..55ecf2db518 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -33,7 +33,10 @@ class mod_task_simple extends ModeleNumRefTask { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='TK'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom = "Simple"; var $name = "Simple"; diff --git a/htdocs/core/modules/project/task/modules_task.php b/htdocs/core/modules/project/task/modules_task.php index 7d14ae12a3e..11fa9b38326 100644 --- a/htdocs/core/modules/project/task/modules_task.php +++ b/htdocs/core/modules/project/task/modules_task.php @@ -32,7 +32,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFTask extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -63,7 +66,10 @@ abstract class ModelePDFTask extends CommonDocGenerator */ abstract class ModeleNumRefTask { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 0e1700da500..cac76d47b5a 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -33,7 +33,10 @@ class mod_propale_marbre extends ModeleNumRefPropales { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='PR'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom = "Marbre"; diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index c2d52923e4f..55f7a028e23 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -36,7 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requ */ abstract class ModelePDFPropales extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -66,7 +69,10 @@ abstract class ModelePDFPropales extends CommonDocGenerator */ abstract class ModeleNumRefPropales { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php index 3129a341926..60378cf03a4 100644 --- a/htdocs/core/modules/security/generate/modules_genpassword.php +++ b/htdocs/core/modules/security/generate/modules_genpassword.php @@ -30,7 +30,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ abstract class ModeleGenPassword { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 0ed5eace2e2..c5a1901635b 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -33,7 +33,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleThirdPartyDoc extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return list of active generation modules @@ -63,7 +66,10 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator */ abstract class ModeleThirdPartyCode { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Renvoi la description par defaut du modele de numerotation * @@ -255,7 +261,10 @@ abstract class ModeleThirdPartyCode */ abstract class ModeleAccountancyCode { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return description of module diff --git a/htdocs/core/modules/stock/modules_movement.php b/htdocs/core/modules/stock/modules_movement.php index 806f500dab7..4009d235b59 100644 --- a/htdocs/core/modules/stock/modules_movement.php +++ b/htdocs/core/modules/stock/modules_movement.php @@ -30,7 +30,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFMovement extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index a0740b50f54..a5e0c2e5d7f 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -23,7 +23,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFStock extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index 7762d8ce6a5..edc3f3c7428 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -34,7 +34,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -64,7 +67,10 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator */ abstract class ModeleNumRefSuppliersInvoices { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return if a model can be used or not * diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index 4bd262d67fb..d20229fd650 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -37,7 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -69,7 +72,10 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator */ abstract class ModeleNumRefSuppliersOrders { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return if a model can be used or not * diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index 9b0012ec089..94521f99c5e 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -31,7 +31,10 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='SPAY'; - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom='Bronan'; diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php index 56c5bd94ae0..7a6e26e770b 100644 --- a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -22,7 +22,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -54,7 +57,10 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator abstract class ModeleNumRefSupplierPayments { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index fa8cf6c6460..372b3189292 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -33,7 +33,10 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='RQ'; // RQ = Request for quotation - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; var $nom = "Marbre"; diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index b324a1b03a8..13ca149fde8 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -36,7 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requ */ abstract class ModelePDFSupplierProposal extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -66,7 +69,10 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator */ abstract class ModeleNumRefSupplierProposal { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/user/modules_user.class.php b/htdocs/core/modules/user/modules_user.class.php index 3e94ece9372..33844eb938c 100644 --- a/htdocs/core/modules/user/modules_user.class.php +++ b/htdocs/core/modules/user/modules_user.class.php @@ -38,7 +38,10 @@ */ abstract class ModelePDFUser extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/core/modules/usergroup/modules_usergroup.class.php b/htdocs/core/modules/usergroup/modules_usergroup.class.php index 26edb08d57c..d6735de5cad 100644 --- a/htdocs/core/modules/usergroup/modules_usergroup.class.php +++ b/htdocs/core/modules/usergroup/modules_usergroup.class.php @@ -38,7 +38,10 @@ */ abstract class ModelePDFUserGroup extends CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d14419f49b0..789a351c776 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -278,6 +278,7 @@ class Fichinter extends CommonObject */ function update($user, $notrigger=0) { + global $conf; if (! is_numeric($this->duration)) { $this->duration = 0; } diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index f8754193515..bc4873770fd 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -44,7 +44,11 @@ class Import var $array_import_run_sql_after; var $error; - var $errors; + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); /** diff --git a/htdocs/index.php b/htdocs/index.php index 902ea6882a6..df1c18176e7 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -565,6 +565,10 @@ if (! empty($valid_dashboardlines)) $sep=($conf->dol_use_jmobile?'
':' '); $boxwork .= ''.$board->img.' '.$board->label.'
'; $boxwork .= ''.$board->nbtodo.''; + if ($board->total > 0 && ! empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) + { + $boxwork .= ' / '.price($board->total) .''; + } $boxwork .= ''; if ($board->nbtodolate > 0) { diff --git a/htdocs/install/doctemplates/projects/template_project.odt b/htdocs/install/doctemplates/projects/template_project.odt index fca796a26dd..b6fd0349ea4 100644 Binary files a/htdocs/install/doctemplates/projects/template_project.odt and b/htdocs/install/doctemplates/projects/template_project.odt differ diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 41554cfd45d..16ca7cc7201 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -477,6 +477,8 @@ davDescription=Add a component to be a DAV server DAVSetup=Setup of module DAV DAV_ALLOW_PUBLIC_DIR=Enable the public directory (WebDav directory with no login required) DAV_ALLOW_PUBLIC_DIRTooltip=The WebDav public directory is a WebDAV directory everybody can access to (in read and write mode), with no need to have/use an existing login/password account. +DAV_ALLOW_ECM_DIR=Enable the root directy of DMS/ECM module (login required) +DAV_ALLOW_ECM_DIRTooltip=The root directory where all files are manually uploaded when using the DMS/ECM module. Like for the feature from the web interface, you will need a valid login/password with granted permissions to access it. # Modules Module0Name=Users & Groups Module0Desc=Users / Employees and Groups management diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 8a720bd422b..6e4de1188a6 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -5,10 +5,10 @@ SelectThirdParty=Select a third party ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited information? DeleteContact=Delete a contact/address ConfirmDeleteContact=Are you sure you want to delete this contact and all inherited information? -MenuNewThirdParty=new Third Party -MenuNewCustomer=new Customer -MenuNewProspect=new Prospect -MenuNewSupplier=new Vendor +MenuNewThirdParty=New Third Party +MenuNewCustomer=New Customer +MenuNewProspect=Nnew Prospect +MenuNewSupplier=New Vendor MenuNewPrivateIndividual=New private individual NewCompany=New company (prospect, customer, vendor) NewThirdParty=New Third Party (prospect, customer, vendor) @@ -333,7 +333,7 @@ NoContactForAnyProposal=This contact is not a contact for any commercial proposa NoContactForAnyContract=This contact is not a contact for any contract NoContactForAnyInvoice=This contact is not a contact for any invoice NewContact=New contact -NewContactAddress=new Contact/Address +NewContactAddress=New Contact/Address MyContacts=My contacts Capital=Capital CapitalOf=Capital of %s diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 5b5382480a1..cf88cf65cc9 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -209,6 +209,7 @@ ErrorFileNotFoundWithSharedLink=File was not found. May be the share key was mod ErrorProductBarCodeAlreadyExists=The product barcode %s already exists on another product reference. ErrorNoteAlsoThatSubProductCantBeFollowedByLot=Note also that using virtual product to have auto increase/decrease of subproducts is not possible when at least one subproduct (or subproduct of subproducts) needs a serial/lot number. ErrorDescRequiredForFreeProductLines=Description is mandatory for lines with free product +ErrorAPageWithThisNameOrAliasAlreadyExists=The page/container %s has the same name or alternative alias that the one your try to use # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. @@ -231,4 +232,4 @@ WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action. WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the mass actions on lists -WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report \ No newline at end of file +WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 9ab397f190c..c87bac6bab1 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -168,8 +168,9 @@ TypeContact_project_task_external_TASKCONTRIBUTOR=Contributor SelectElement=Select element AddElement=Link to element # Documents models -DocumentModelBeluga=Project template for linked objects overview -DocumentModelBaleine=Project report template for tasks +DocumentModelBeluga=Project document template for linked objects overview +DocumentModelBaleine=Project document template for tasks +DocumentModelTimeSpent=Project report template for time spent PlannedWorkload=Planned workload PlannedWorkloadShort=Workload ProjectReferers=Related items @@ -229,3 +230,4 @@ DontHavePermissionForCloseProject=You do not have permissions to close the proje DontHaveTheValidateStatus=The project %s must be open to be closed RecordsClosed=%s project(s) closed SendProjectRef=Information project %s +ModuleSalaryToDefineHourlyRateMustBeEnabled=Module 'Payment of employee wages' must be enabled to define employee hourly rate to have time spent valorized diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index fe3a4b7cf92..ef2b70b685a 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -47,6 +47,7 @@ PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will PreviewSiteServedByDolibarr=Preview %s in a new tab.

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

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet +YouCanCreatePageOrImportTemplate=You can create a new page or import a full website template SyntaxHelp=Help on specific syntax tips YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor. YouCanEditHtmlSource=
You can include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Container with the following syntax:
<?php includeContainer('alias_of_container_to_include'); ?>

You can make a redirect to another Page/Container with the following syntax:
<?php redirectToContainer('alias_of_container_to_redirect_to'); ?>

To include a link to download a file stored into the documents directory, use the document.php wrapper:
Example, for a file into documents/ecm (need to be logged), syntax is:
<a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext">
For a file into documents/medias (open directory for public access), syntax is:
<a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext">
For a file shared with a share link (open access using the sharing hash key of file), syntax is:
<a href="/document.php?hashp=publicsharekeyoffile">

To include an image stored into the documents directory, use the viewimage.php wrapper:
Example, for an image into documents/medias (open access), syntax is:
<a href="/viewimage.php?modulepart=medias&file=[relative_dir/]filename.ext">
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index acb04734234..26dcb94a0ba 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1170,12 +1170,15 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $ext='layout='.$conf->browser->layout.'&version='.urlencode(DOL_VERSION); print "\n"; + if (GETPOST('dol_basehref','alpha')) print ''."\n"; + // Displays meta print ''."\n"; print ''."\n"; // Do not index print ''."\n"; // Scale for mobile device print ''."\n"; + // Favicon $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; @@ -1184,6 +1187,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; + // Auto refresh page + if (GETPOST('autorefresh','int') > 0) print ''; + // Displays title $appli=constant('DOL_APPLICATION_TITLE'); if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index 5ce3068c144..c5bf6808fac 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -31,7 +31,12 @@ class PriceExpression { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $id; var $title; var $expression; diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index 97a3ee1f4e6..1432afcfdeb 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -31,7 +31,12 @@ class PriceGlobalVariable { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $id; var $code; var $description; diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index f4595062098..37a3e116683 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -31,7 +31,12 @@ class PriceGlobalVariableUpdater { var $db; //!< To store db handler var $error; //!< To return error code (or message) - var $errors=array(); //!< To return several error codes (or messages) + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + var $types=array(0, 1); //!< Updater types var $update_min = 5; //!< Minimal update rate var $id; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 593711290d3..9b26eecc426 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -744,22 +744,34 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) + // Duration + if (! empty($arrayfields['p.duration']['checked'])) { - if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); - else print $obj->duration; + print ''; + + if (preg_match('/([^a-z]+)[a-z]$/i',$obj->duration)) + { + $duration_value = substr($obj->duration,0,dol_strlen($obj->duration)-1); + $duration_unit = substr($obj->duration,-1); + + if ((float) $duration_value > 1) + { + $dur=array("i"=>$langs->trans("Minutes"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else if ((float) $duration_value > 0) + { + $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $duration_value; + print (! empty($duration_unit) && isset($dur[$duration_unit]) ? ' '.$langs->trans($dur[$duration_unit]) : ''); + } + else + { + print $obj->duration; + } + print ''; + if (! $i) $totalarray['nbfield']++; } - print ''; - if (! $i) $totalarray['nbfield']++; - } // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 7e13da391f2..bc5d03c7296 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Laurent Destaileur + * Copyright (C) 2013-2018 Laurent Destaileur * Copyright (C) 2014 Regis Houssin * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2016 ATM Consulting diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 6c4b7f56d3f..c1b6c1b2848 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -278,6 +278,6 @@ if ($id > 0 || ! empty($ref)) } } - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index 0250bb2c39f..614b10c976a 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -94,6 +94,6 @@ $array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3'); $arrayselected=array(1,3); print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, '', 0, 250); - +// End of page llxFooter(); $db->close(); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index e4a21ae9888..5ba98ae9f69 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -401,8 +401,6 @@ else { dol_print_error(); } - - // End of page llxFooter(); $db->close(); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index b844fce0f6c..adbd8eec87f 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -473,6 +473,6 @@ else } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 37082f4140b..15383883e97 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -37,10 +37,17 @@ abstract class ActionsCardCommon var $tpl = array(); //! Object container var $object; - //! Error string - var $error; - //! Error array - var $errors=array(); + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); /** diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 8ad547a47ee..f0c950d85ac 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -1113,6 +1113,6 @@ if (! GETPOST('action')) } } +// End of page llxFooter(); - $db->close(); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6c57af79de2..528d56dcdba 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1514,7 +1514,7 @@ else // Date employment print ''.$langs->trans("DateEmployment").''; print ''; - print dol_print_date($object->dateemployment); + print dol_print_date($object->dateemployment, 'day'); print ''; print "\n"; @@ -1845,7 +1845,7 @@ else if ($caneditgroup) { print ''; - print img_delete($langs->trans("RemoveFromGroup")); + print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print ''; } else diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index c21049a5c76..0110d9db789 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -1,6 +1,6 @@ +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Frédéric France * * 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 @@ -62,9 +62,9 @@ print ''.$langs->trans('HideProductCombinations').' print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD",$conf->global->PRODUIT_ATTRIBUTES_HIDECHILD,1).''; print ''.$langs->trans('CombinationsSeparator').''; if(isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR; + $separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR; } else { - $separator = "_"; + $separator = "_"; } print ''; print ''; @@ -74,4 +74,3 @@ print ''; // End of page llxFooter(); $db->close(); - diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 3f298ae93e6..9f3dafdc153 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Frédéric France * * 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 @@ -50,7 +51,7 @@ if ($_POST) { $object->label = $label; if ($object->update($user) < 1) { - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), $object->errors, 'errors'); } else { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); @@ -79,7 +80,7 @@ if ($_POST) { if ($objectval->update($user) > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } else { - setEventMessage($langs->trans('CoreErrorMessage'), null, 'errors'); + setEventMessage($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors'); } } } @@ -99,7 +100,7 @@ if ($confirm == 'yes') { if ($res < 1 || ($object->delete() < 1)) { $db->rollback(); - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), $object->errors, 'errors'); header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); } else { $db->commit(); @@ -113,7 +114,7 @@ if ($confirm == 'yes') { if ($objectval->fetch($valueid) > 0) { if ($objectval->delete() < 1) { - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + setEventMessages($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors'); } else { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 636824d1980..62c5386d65d 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -1,6 +1,7 @@ - * Copyright (C) 2017 Laurent Destailleur +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2018 Frédéric France * * 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 @@ -449,7 +450,7 @@ if (! empty($id) || ! empty($ref)) if($valueid > 0) { print ''."\n"; } - + print dol_fiche_head(); ?> diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index c3fbc39b82c..0e491be448d 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Frédéric France * * 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,7 +50,7 @@ if ($_POST) { } exit; } else { - setEventMessage($langs->trans('ErrorRecordAlreadyExists'), 'errors'); + setEventMessages($langs->trans('ErrorRecordAlreadyExists'), $prodattr->errors, 'errors'); } } } diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index 74da8a8043e..8213148327d 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Frédéric France * * 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 @@ -70,7 +71,7 @@ if ($action == 'add') header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); } else { - setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), null, 'errors'); + setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), $objectval->errors, 'errors'); } } } diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index c2883d577aa..49265f25001 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -1,6 +1,6 @@ +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Frédéric France * * 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 @@ -374,5 +374,8 @@ if (! empty($id) || ! empty($ref)) { close(); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 9e128329cad..ed49d4a43d7 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -802,13 +802,13 @@ class Website extends CommonObject dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); $srcdir = DOL_DATA_ROOT.'/medias/image/'.$website->ref; - $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/image/'.$website->ref; + $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/image/websitekey'; dol_syslog("Copy content from ".$srcdir." into ".$destdir); dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); $srcdir = DOL_DATA_ROOT.'/medias/js/'.$website->ref; - $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/js/'.$website->ref; + $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/js/websitekey'; dol_syslog("Copy content from ".$srcdir." into ".$destdir); dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); @@ -853,22 +853,47 @@ class Website extends CommonObject } foreach($listofpages as $pageid => $objectpageold) { - $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, title, description, keyword, status, date_creation, tms, lang, import_key, grabbed_from, content)'; + $allaliases = $objectpageold->pageurl; + $allaliases.= ($objectpageold->aliasalt ? ','.$objectpageold->aliasalt : ''); + + $line = '-- Page ID '.$objectpageold->id.' -> '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; + $line.= "\n"; + fputs($fp, $line); + + // Warning: We must keep llx_ here. It is a generic SQL. + $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, keywords, status, date_creation, tms, lang, import_key, grabbed_from, type_container, htmlheader, content)'; $line.= " VALUES("; - $line.= $objectpageold->newid."+__MAXROWID__, "; - $line.= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."+__MAXROWID__" : "null").", "; + $line.= $objectpageold->newid."__+MAX_llx_website_page__, "; + $line.= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."__+MAX_llx_website_page__" : "null").", "; $line.= "__WEBSITE_ID__, "; $line.= "'".$this->db->escape($objectpageold->pageurl)."', "; + $line.= "'".$this->db->escape($objectpageold->aliasalt)."', "; $line.= "'".$this->db->escape($objectpageold->title)."', "; $line.= "'".$this->db->escape($objectpageold->description)."', "; - $line.= "'".$this->db->escape($objectpageold->keyword)."', "; + $line.= "'".$this->db->escape($objectpageold->keywords)."', "; $line.= "'".$this->db->escape($objectpageold->status)."', "; $line.= "'".$this->db->idate($objectpageold->date_creation)."', "; $line.= "'".$this->db->idate($objectpageold->date_modification)."', "; $line.= "'".$this->db->escape($objectpageold->lang)."', "; $line.= ($objectpageold->import_key ? "'".$this->db->escape($objectpageold->import_key)."'" : "null").", "; $line.= "'".$this->db->escape($objectpageold->grabbed_from)."', "; - $line.= "'".$this->db->escape($objectpageold->content)."'"; + $line.= "'".$this->db->escape($objectpageold->type_container)."', "; + + $stringtoexport = $objectpageold->htmlheader; + $stringtoexport = str_replace(array("\r\n","\r","\n"), "__N__", $stringtoexport); + $stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport); + $line.= "'".$this->db->escape(str_replace(array("\r\n","\r","\n"), "__N__", $stringtoexport))."', "; // Replace \r \n to have record on 1 line + + $stringtoexport = $objectpageold->content; + $stringtoexport = str_replace(array("\r\n","\r","\n"), "__N__", $stringtoexport); + $stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport); + $line.= "'".$this->db->escape($stringtoexport)."'"; // Replace \r \n to have record on 1 line $line.= ");"; $line.= "\n"; fputs($fp, $line); @@ -879,7 +904,7 @@ class Website extends CommonObject @chmod($filesql, octdec($conf->global->MAIN_UMASK)); // Build zip file - $filedir = $conf->website->dir_temp.'/'.$website->ref; + $filedir = $conf->website->dir_temp.'/'.$website->ref.'/.'; $fileglob = $conf->website->dir_temp.'/'.$website->ref.'/website_'.$website->ref.'-*.zip'; $filename = $conf->website->dir_temp.'/'.$website->ref.'/website_'.$website->ref.'-'.dol_print_date(dol_now(),'dayhourlog').'.zip'; @@ -900,9 +925,17 @@ class Website extends CommonObject { global $conf; - $result = 0; + $error = 0; - $object = new Website($this->db); + $object = $this; + if (empty($object->ref)) + { + $this->error = 'Function importWebSite called on object not loaded (object->ref is empty)'; + return -1; + } + + dol_delete_dir_recursive(dirname($pathtofile).'/'.$object->ref); + dol_mkdir(dirname($pathtofile).'/'.$object->ref); $filename = basename($pathtofile); if (! preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) @@ -911,13 +944,84 @@ class Website extends CommonObject return -1; } - $websitecode = $reg[1]; - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."website(ref, entity, description, status) values('".$websitecode."', ".$conf->entity.", 'Portal to sell your SaaS. Do not remove this entry.', 1)"; - $resql = $this->db->query($sql); + $result = dol_uncompress($pathtofile, $conf->website->dir_temp.'/'.$object->ref); + if (! empty($result['error'])) + { + $this->errors[]='Failed to unzip file '.$pathtofile.'.'; + return -1; + } - return $result; + dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/containers', $conf->website->dir_output.'/'.$object->ref, 0, 1); // Overwrite if exists + + dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists + dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists + + $sqlfile = $conf->website->dir_temp.'/'.$object->ref.'/website_pages.sql'; + + $arrayreplacement = array(); + $arrayreplacement['__WEBSITE_ID__'] = $object->id; + $arrayreplacement['__WEBSITE_KEY__'] = $object->ref; + $arrayreplacement['__N__'] = $this->db->escape("\n"); // Restore \n + $result = dolReplaceInFile($sqlfile, $arrayreplacement); + + $this->db->begin(); + + $sqlgetrowid='SELECT MAX(rowid) as max from '.MAIN_DB_PREFIX.'website_page'; + $resql=$this->db->query($sqlgetrowid); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $maxrowid=$obj->max; + } + + $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); + if ($runsql <= 0) + { + $this->errors[]='Failed to load sql file '.$sqlfile.'.'; + $error++; + } + + $objectpagestatic = new WebsitePage($this->db); + + // Make replacement of IDs + $fp = fopen($sqlfile,"r"); + if ($fp) + { + while (! feof($fp)) + { + // Warning fgets with second parameter that is null or 0 hang. + $buf = fgets($fp, 65000); + if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) + { + $oldid = $reg[1]; + $newid = ($reg[2] + $maxrowid); + $aliasesarray = explode(',', $reg[3]); + + dol_syslog("Found ID ".$oldid." to replace with ID ".$newid." and shortcut aliases to create: ".$reg[3]); + + dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + + foreach($aliasesarray as $aliasshortcuttocreate) + { + $objectpagestatic->id = $newid; + $filealias=$conf->website->dir_output.'/'.$object->ref.'/'.$aliasshortcuttocreate.'.php'; + dolSavePageAlias($filealias, $object, $objectpagestatic); + } + } + } + } + + if ($error) + { + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return $object->id; + } } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 10cbc3381f6..d816d1564bb 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -125,7 +125,9 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object. If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set. + * @param int $id Id object. + * If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set. + * If value is < 0, we must exclude this ID. * @param string $website_id Web site id (page name must also be filled if this parameter is used) * @param string $page Page name (website id must also be filled if this parameter is used) * @param string $aliasalt Alternative alias to search page (slow) @@ -162,6 +164,7 @@ class WebsitePage extends CommonObject } else { + if ($id < 0) $sql .= ' AND t.rowid <> ' . abs($id); if (null !== $website_id) { $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index af6b1312cbc..5a7916f6bd9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -229,6 +229,7 @@ if ($action == 'addsite') if (! $error && ! GETPOST('WEBSITE_REF','alpha')) { $error++; + $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF','alpha'))) @@ -962,7 +963,7 @@ if ($action == 'updatemeta') { $db->begin(); - $object->fetch(0, $websitekey); + $result = $object->fetch(0, $websitekey); $website = $object; $objectpage->fk_website = $object->id; @@ -976,13 +977,59 @@ if ($action == 'updatemeta') $action='editmeta'; } - $res = $objectpage->fetch($pageid, $object->fk_website); + $res = $objectpage->fetch($pageid, $object->id); if ($res <= 0) { $error++; setEventMessages('Page not found '.$objectpage->error, $objectpage->errors, 'errors'); } + // Check alias not exists + if (! $error && GETPOST('WEBSITE_PAGENAME', 'alpha')) + { + $websitepagetemp=new WebsitePage($db); + $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha')); + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($websitepagetemp->error, $websitepagetemp->errors, 'errors'); + $action = 'editmeta'; + } + if ($result > 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null, 'errors'); + $action = 'editmeta'; + } + } + if (! $error && GETPOST('WEBSITE_ALIASALT', 'alpha')) + { + $arrayofaliastotest=explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); + $websitepagetemp=new WebsitePage($db); + foreach($arrayofaliastotest as $aliastotest) + { + $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest); + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($websitepagetemp->error, $websitepagetemp->errors, 'errors'); + $action = 'editmeta'; + break; + } + if ($result > 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null, 'errors'); + $action = 'editmeta'; + break; + } + } + } + if (! $error) { $objectpage->old_object = clone $objectpage; @@ -997,10 +1044,23 @@ if ($action == 'updatemeta') $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $res = $objectpage->update($user); - if (! $res > 0) + if (! ($res > 0)) { - $error++; - setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + $langs->load("errors"); + if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists"), null, 'errors'); + $action = 'editmeta'; + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + $action = 'editmeta'; + } } } @@ -1276,7 +1336,11 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - if (! $error) setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); + if (! $error) + { + setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); + setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings'); + } } } @@ -1301,28 +1365,63 @@ if ($action == 'exportsite') // Import site if ($action == 'importsiteconfirm') { - $fileofzip = GETPOST('userfile'); - if (empty($fileofzip)) + if (empty($_FILES)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; } else { - // TODO - - - $result = $object->importWebSite($fileofzip); - if ($result < 0) + if (! empty($_FILES)) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'importsite'; - } - else - { - header("Location: aaaaa"); - exit(); + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; + else $userfiles=array($_FILES['userfile']['tmp_name']); + + foreach($userfiles as $key => $userfile) + { + if (empty($_FILES['userfile']['tmp_name'][$key])) + { + $error++; + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); + $action = 'importsite'; + } + else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); + $action = 'importsite'; + } + } + } + + if (! $error) + { + $upload_dir = $conf->website->dir_temp; + $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); + + // Get name of file (take last one if several name provided) + $fileofzip = $upload_dir.'/unknown'; + foreach($_FILES as $key => $ifile) + { + foreach($ifile['name'] as $key2 => $ifile2) + { + $fileofzip = $upload_dir . '/' .$ifile2; + } + } + + $result = $object->importWebSite($fileofzip); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'importsite'; + } + else + { + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$object->ref); + exit(); + } + } } + } } diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 0bc4428deb2..49009d8f4e7 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -382,7 +382,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } - // End of page llxFooter(); $db->close();