diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 2eedcda8760..0e3b2c7513f 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -295,6 +295,7 @@ 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; + if (preg_match('/InDolibarr$/', $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; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 76b3cf76b57..0dba6ea6700 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -67,6 +67,8 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'', $conf->entity); + + dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'', $conf->entity); @@ -572,31 +574,36 @@ else // Show print ""; print ''; - //Desc + // Hide Desc print ''.$langs->trans("HideDescOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1); print ''; - //Ref + // Hide Ref print ''.$langs->trans("HideRefOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1); print ''; - //Details + // Hide Details print ''.$langs->trans("HideDetailsOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); print ''; + // Invert sender and recipient + print ''.$langs->trans("SwapSenderAndRecipientOnPDF").''; + print yn($conf->global->MAIN_INVERT_SENDER_RECIPIENT,1); + print ''; - print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; + // Use French location + print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; print yn($conf->global->MAIN_PDF_USE_ISO_LOCATION,1); print ''; - print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; + print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; print $arraydetailsforpdffoot[($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)]; print ''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 469db6f2a54..a2e63da99cc 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -874,7 +874,7 @@ else } } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; $nbtry = $nbok = 0; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 7a0d758ae17..bb6ac93d1c2 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -530,6 +530,81 @@ class Mailing extends CommonObject } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("ShowEmailing") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowEmailing"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action; + $hookmanager->initHooks(array('emailingdao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + /** * Return label of status of emailing (draft, validated, ...) * diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 5087698b9ab..133a354723f 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -35,15 +35,15 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="m.date_creat"; -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$sref=GETPOST("sref", "alpha"); +$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); $filteremail=GETPOST('filteremail','alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -59,6 +59,53 @@ $fieldstosearchall = array( 'm.titre'=>'Ref', ); +$object = new Mailing($db); + + + +/* + * Actions + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + /*foreach($object->fields as $key => $val) + { + $search[$key]=''; + }*/ + $search_ref = ''; + $search_all = ''; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} /* @@ -76,8 +123,8 @@ if ($filteremail) $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; - if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; - if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; + if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); @@ -88,8 +135,8 @@ else $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " WHERE m.entity = ".$conf->entity; - if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; - if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; + if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); @@ -115,7 +162,7 @@ if ($result) $i = 0; - $param = "&sall=".urlencode($sall); + $param = "&search_all=".urlencode($search_all); if ($filteremail) $param.='&filteremail='.urlencode($filteremail); print '
'; @@ -135,11 +182,11 @@ if ($result) print ''; print ''; - print ''; + print ''; print ''; // Title print ''; - print ''; + print ''; print ''; print ' '; if (! $filteremail) print ' '; @@ -169,16 +216,22 @@ if ($result) { $obj = $db->fetch_object($result); - + $email->id = $obj->rowid; + $email->ref = $obj->rowid; print ""; - print ''; - print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).''; + + print ''; + print $email->getNomUrl(1); + print ''; + print ''.$obj->titre.''; // Date creation + print ''; print dol_print_date($db->jdate($obj->datec),'day'); print ''; + // Nb of email if (! $filteremail) { @@ -196,9 +249,11 @@ if ($result) print $nbemail; print ''; } + // Last send print ''.dol_print_date($db->jdate($obj->date_envoi),'day').''; print ''; + // Status print ''; if ($filteremail) @@ -210,7 +265,9 @@ if ($result) print $email->LibStatut($obj->statut,5); } print ''; + print ''; + print "\n"; $i++; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index b58619b66a2..2325d30a26a 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -60,7 +60,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('bankcard','globalcard')); /* * Actions diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 2389d1fec77..9bd00c81894 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -49,6 +49,9 @@ $result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fie $vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"]; $page=isset($_GET["page"])?$_GET["page"]:0; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('banktreso','globalcard')); + /* * View */ @@ -130,6 +133,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Remainder to pay in future + $sqls = array(); // Customer invoices $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; @@ -138,79 +142,55 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice - $sql.= " ORDER BY dlr ASC"; + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Supplier invoices - $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; - $sql2.= " s.rowid as socid, s.nom as name, s.fournisseur"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; - $sql2.= " WHERE ff.entity = ".$conf->entity; - $sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql2.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice - $sql2.= " ORDER BY dlr ASC"; + $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; + $sql.= " s.rowid as socid, s.nom as name, s.fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; + $sql.= " WHERE ff.entity = ".$conf->entity; + $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid + $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Social contributions - $sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; - $sql3.= ", cs.fk_account"; - $sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; - $sql3.= " WHERE cs.entity = ".$conf->entity; - $sql3.= " AND cs.paye = 0"; // Not paid - $sql3.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution - $sql3.= " ORDER BY dlr ASC"; + $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; + $sql.= ", cs.fk_account"; + $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; + $sql.= " WHERE cs.entity = ".$conf->entity; + $sql.= " AND cs.paye = 0"; // Not paid + $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; + + // others sql + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook) and isset($hookmanager->resArray['sql'])){ + $sqls[] = $hookmanager->resArray['sql']; + } $error=0; $tab_sqlobjOrder=array(); $tab_sqlobj=array(); - // List customer invoices - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result); - } - else $error++; - - // List supplier invoices - $result2=$db->query($sql2); - if ($result2) - { - $num = $db->num_rows($result2); - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result2); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result2); - } - else $error++; - - // List social contributions - $result3=$db->query($sql3); - if ($result3) - { - $num = $db->num_rows($result3); - - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result3); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result3); - } - else $error++; - + foreach($sqls as $sql){ + $resql = $db->query($sql); + if($resql){ + while($sqlobj = $db->fetch_object($resql)){ + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); + } + $db->free($resql); + }else{ + $error++; + } + } // Sort array if (! $error) @@ -228,7 +208,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $num = count($tab_sqlobj); - //$num = $db->num_rows($result); $i = 0; while ($i < $num) { @@ -236,7 +215,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $ref = ''; $refcomp = ''; - //$obj = $db->fetch_object($result); $obj = array_shift($tab_sqlobj); if ($obj->family == 'invoice_supplier') @@ -284,6 +262,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } + $parameters = array('obj' => $obj); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + } + $total_ttc = $obj->total_ttc; if ($paiement) $total_ttc = $obj->total_ttc - $paiement; $solde += $total_ttc; @@ -291,8 +277,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // We discard lines with a remainder to pay to 0 if (price2num($total_ttc) != 0) { - - // Show line print ''; print ''; @@ -315,15 +299,22 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) dol_print_error($db); } - // Solde actuel + // Other lines + $parameters = array('solde' => $solde); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + print $hookmanager->resPrint; + $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; + } + // solde print ''; print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.')'; print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; print ''; print ""; - print ""; + print ""; } else { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0773e6eedc1..3ab5d84bfdb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1982,7 +1982,8 @@ class Facture extends CommonInvoice if (! dol_delete_file($file,0,0,0,$this)) // For triggers { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + $langs->load("errors"); + $this->error=$langs->trans("ErrorFailToDeleteFile",$file); $this->db->rollback(); return 0; } @@ -1991,7 +1992,8 @@ class Facture extends CommonInvoice { if (! dol_delete_dir_recursive($dir)) // For remove dir and meta { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + $langs->load("errors"); + $this->error=$langs->trans("ErrorFailToDeleteDir",$dir); $this->db->rollback(); return 0; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 3fdfbc0c514..72cfa38e8c2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -903,7 +903,8 @@ if ($resql) print "\n"; $projectstatic=new Project($db); - + $discount = new DiscountAbsolute($db); + if ($num > 0) { $i=0; @@ -920,6 +921,9 @@ if ($resql) $facturestatic->total_tva=$obj->total_vat; $facturestatic->total_ttc=$obj->total_ttc; $facturestatic->statut=$obj->fk_statut; + $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->paye=$obj->paye; + $facturestatic->fk_soc=$obj->fk_soc; $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $facturestatic->note_public=$obj->note_public; $facturestatic->note_private=$obj->note_private; @@ -939,7 +943,12 @@ if ($resql) $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; - $remaintopay = $obj->total_ttc - $totalpay; + $remaintopay = $facturestatic->total_ttc - $totalpay; + if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { + $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); + $remaintopay = -$remaincreditnote; + $totalpay = $facturestatic->total_ttc - $remaintopay; + } print ''; if (! empty($arrayfields['f.facnumber']['checked'])) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9e1757fdc5a..babc7e1453a 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -186,6 +186,8 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id",'int'); $object->state_id = GETPOST("state_id",'int'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->email = GETPOST("email",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); @@ -358,6 +360,8 @@ if (empty($reshook)) $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); $object->phone_mobile = GETPOST("phone_mobile",'alpha'); @@ -658,13 +662,28 @@ else // Instant message and no email print ''; - print 'jabberid).'">'; + print 'jabberid).'">'; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print ''; - print 'skype).'">'; + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print 'skype).'">'; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print 'twitter).'">'; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print 'facebook).'">'; + } } // Visibility @@ -914,11 +933,26 @@ else } print ''; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print ''; - print 'skype).'">'; + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print 'skype).'">'; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print 'twitter).'">'; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print 'facebook).'">'; + } } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e5fc015da93..b8cadaa4632 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -354,6 +354,8 @@ class Contact extends CommonObject $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; $sql .= ", skype='".$this->db->escape($this->skype)."'"; + $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; + $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -441,6 +443,16 @@ class Contact extends CommonObject $tmpobj->skype = $this->skype; $usermustbemodified++; } + if ($tmpobj->twitter != $this->twitter) + { + $tmpobj->twitter = $this->twitter; + $usermustbemodified++; + } + if ($tmpobj->facebook != $this->facebook) + { + $tmpobj->facebook = $this->facebook; + $usermustbemodified++; + } if ($usermustbemodified) { $result=$tmpobj->update($user, 0, 1, 1, 1); @@ -690,7 +702,7 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,"; $sql.= " c.import_key,"; @@ -756,6 +768,8 @@ class Contact extends CommonObject $this->email = $obj->email; $this->jabberid = $obj->jabberid; $this->skype = $obj->skype; + $this->twitter = $obj->twitter; + $this->facebook = $obj->facebook; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -1069,9 +1083,9 @@ class Contact extends CommonObject function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'"; - $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes + $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m"; + $sql.= " WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email)."' "; + $sql.= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index d18501d54d9..c67e3f5f59d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -40,7 +40,10 @@ class AntiVir */ public $errors = array(); - var $output; + /** + * @var string Used to return message + */ + public $output; /** * @var DoliDB Database handler. diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index a4665701661..cf830048cc0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -43,15 +43,15 @@ class Canvas */ public $errors = array(); - var $actiontype; + public $actiontype; - var $dirmodule; // Module directory - var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) - var $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 475fbf2b1f0..9e85bac1fec 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2899,6 +2899,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; + if ($origin == 'invoice_template') $origin='facturerec'; $this->db->begin(); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 618716ce0e4..ad7b900b033 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -39,46 +39,46 @@ */ class DolGraph { - var $type=array(); // Array with type of each series. Example: array('bars', 'lines', ...) - var $mode='side'; // Mode bars graph: side, depth + public $type=array(); // Array with type of each series. Example: array('bars', 'lines', ...) + public $mode='side'; // Mode bars graph: side, depth private $_library='jflot'; // Graphic library to use (jflot, artichow) //! Array of data - var $data; // Data of graph: array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) - var $title; // Title of graph - var $cssprefix=''; // To add into css styles - var $width=380; - var $height=200; - var $MaxValue=0; - var $MinValue=0; - var $SetShading=0; + public $data; // Data of graph: array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) + public $title; // Title of graph + public $cssprefix=''; // To add into css styles + public $width=380; + public $height=200; + public $MaxValue=0; + public $MinValue=0; + public $SetShading=0; - var $PrecisionY=-1; + public $PrecisionY=-1; - var $horizTickIncrement=-1; - var $SetNumXTicks=-1; - var $labelInterval=-1; + public $horizTickIncrement=-1; + public $SetNumXTicks=-1; + public $labelInterval=-1; - var $hideXGrid=false; - var $hideYGrid=false; + public $hideXGrid=false; + public $hideYGrid=false; - var $Legend=array(); - var $LegendWidthMin=0; - var $showlegend=1; - var $showpointvalue=1; - var $showpercent=0; - var $combine=0; // 0.05 if you want to combine records < 5% into "other" - var $graph; // Objet Graph (Artichow, Phplot...) + public $Legend=array(); + public $LegendWidthMin=0; + public $showlegend=1; + public $showpointvalue=1; + public $showpercent=0; + public $combine=0; // 0.05 if you want to combine records < 5% into "other" + public $graph; // Objet Graph (Artichow, Phplot...) /** * @var string Error code (or message) */ public $error=''; - var $bordercolor; // array(R,G,B) - var $bgcolor; // array(R,G,B) - var $bgcolorgrid=array(255,255,255); // array(R,G,B) - var $datacolor; // array(array(R,G,B),...) + public $bordercolor; // array(R,G,B) + public $bgcolor; // array(R,G,B) + public $bgcolorgrid=array(255,255,255); // array(R,G,B) + public $datacolor; // array(array(R,G,B),...) private $stringtoshow; // To store string to output graph into HTML page diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2c7b5e2fabb..149f1681725 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6370,6 +6370,7 @@ class Form 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), + 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), @@ -6432,8 +6433,7 @@ class Form { $objp = $this->db->fetch_object($resqllist); - $var = ! $var; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f9fc04d47de..4a59e28f044 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -185,7 +185,7 @@ class FormFile if ($linkfiles) { - $out .= "\n\n"; + $out .= "\n\n"; $langs->load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); @@ -213,19 +213,18 @@ class FormFile $out .= ''; $out .= '
'; $out .= '

'; - $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); - $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); - $out .= "\n\n"; + $out .= "\n\n"; } + $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); + $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); if (empty($res)) { print '
'; print $out; print '
'; } - print $hookmanager->resPrint; return 1; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index b7ae66da36c..8715d979c4d 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -341,7 +341,7 @@ class Utils { // Renommer fichier sortie en fichier erreur //print "$outputfile -> $outputerror"; - @dol_delete_file($outputerror,1); + @dol_delete_file($outputerror, 1, 0, 0, null, false, 0); @rename($outputfile,$outputerror); // Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide if (! $errormsg) @@ -448,7 +448,7 @@ class Utils { $i++; if ($i <= $keeplastnfiles) continue; - dol_delete_file($val['fullname']); + dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); } } @@ -675,8 +675,9 @@ class Utils } /** - * This saves syslog files and compresses older ones - * Used from cronjob + * This saves syslog files and compresses older ones. + * Nb of archive to keep is defined into $conf->global->SYSLOG_FILE_SAVES + * CAN BE A CRON TASK * * @return int 0 if OK, < 0 if KO */ @@ -714,50 +715,52 @@ class Utils $logname = $file['name']; $logpath = $file['path']; - // Handle already compressed files to rename them and add +1 + if (dol_is_file($logpath.'/'.$logname) && dol_filesize($logpath.'/'.$logname) > 0) // If log file exists and is not empty + { + // Handle already compressed files to rename them and add +1 - $filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$'; + $filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$'; - $gzfilestmp = dol_dir_list($logpath, 'files', 0, $filter); - $gzfiles = array(); + $gzfilestmp = dol_dir_list($logpath, 'files', 0, $filter); + $gzfiles = array(); - foreach($gzfilestmp as $gzfile) { - $tabmatches = array(); - preg_match('/'.$filter.'/i', $gzfile['name'], $tabmatches); + foreach($gzfilestmp as $gzfile) { + $tabmatches = array(); + preg_match('/'.$filter.'/i', $gzfile['name'], $tabmatches); - $numsave = intval($tabmatches[1]); + $numsave = intval($tabmatches[1]); - $gzfiles[$numsave] = $gzfile; - } - - krsort($gzfiles, SORT_NUMERIC); - - foreach($gzfiles as $numsave => $dummy) { - if (dol_is_file($logpath.'/'.$logname.'.'.($numsave+1).'.gz')) { - return -2; + $gzfiles[$numsave] = $gzfile; } - if($numsave >= $nbSaves) { - dol_delete_file($logpath.'/'.$logname.'.'.$numsave.'.gz'); - } else { - dol_move($logpath.'/'.$logname.'.'.$numsave.'.gz', $logpath.'/'.$logname.'.'.($numsave+1).'.gz', 0, 1, 0, 0); - } - } + krsort($gzfiles, SORT_NUMERIC); - // Compress last save - if (dol_is_file($logpath.'/'.$logname.'.1')) { - if($nbSaves > 1) { - $gzfilehandle = gzopen($logpath.'/'.$logname.'.2.gz', 'wb9'); + foreach($gzfiles as $numsave => $dummy) { + if (dol_is_file($logpath.'/'.$logname.'.'.($numsave+1).'.gz')) { + return -2; + } + + if($numsave >= $nbSaves) { + dol_delete_file($logpath.'/'.$logname.'.'.$numsave.'.gz', 0, 0, 0, null, false, 0); + } else { + dol_move($logpath.'/'.$logname.'.'.$numsave.'.gz', $logpath.'/'.$logname.'.'.($numsave+1).'.gz', 0, 1, 0, 0); + } + } + + // Compress current file and recreate it + + if ($nbSaves > 0) { // If $nbSaves is 1, we keep 1 archive .gz file, If 2, we keep 2 .gz files + $gzfilehandle = gzopen($logpath.'/'.$logname.'.1.gz', 'wb9'); if (empty($gzfilehandle)) { - $this->error = 'Failted to open file '.$logpath.'/'.$logname.'.2.gz'; + $this->error = 'Failted to open file '.$logpath.'/'.$logname.'.1.gz'; return -3; } - $sourcehandle = fopen($logpath.'/'.$logname.'.1', 'r'); + $sourcehandle = fopen($logpath.'/'.$logname, 'r'); if (empty($sourcehandle)) { - $this->error = 'Failed to open file '.$logpath.'/'.$logname.'.1'; + $this->error = 'Failed to open file '.$logpath.'/'.$logname; return -4; } @@ -767,19 +770,18 @@ class Utils fclose($sourcehandle); gzclose($gzfilehandle); - } else { - dol_delete_file($logpath.'/'.$logname.'.1'); - } - } - // Compress current file et recreate it - - if (dol_is_file($logpath.'/'.$logname)) { - if (dol_move($logpath.'/'.$logname, $logpath.'/'.$logname.'.1', 0, 1, 0, 0)) - { - $newlog = fopen($logpath.'/'.$logname, 'a+'); - fclose($newlog); + @chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); } + + dol_delete_file($logpath.'/'.$logname, 0, 0, 0, null, false, 0); + + // Create empty file + $newlog = fopen($logpath.'/'.$logname, 'a+'); + fclose($newlog); + + //var_dump($logpath.'/'.$logname." - ".octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); + @chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4df32ca4a35..5aff804b4da 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1133,10 +1133,11 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable * @param int $nohook Disable all hooks * @param object $object Current object in use * @param boolean $allowdotdot Allow to delete file path with .. inside. Never use this, it is reserved for migration purpose. + * @param int $indexdatabase Try to remove also index entries. * @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error * @see dol_delete_dir */ -function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null,$allowdotdot=false) +function dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1) { global $db, $conf, $user, $langs; global $hookmanager; @@ -1200,7 +1201,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n { $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete); - if (is_object($db)) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1) + if (is_object($db) && $indexdatabase) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1) { dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 30e9c054262..8b7e4b70c63 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5213,6 +5213,11 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, } } + // Si (vendeur en France et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + if (! empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany()) { + return get_product_vat_for_country($idprod,$thirdparty_seller,$idprodfournprice); + } + // Sinon la TVA proposee par defaut=0. Fin de regle. // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe //print 'VATRULE 5'; @@ -6154,12 +6159,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray=array_merge($substitutionarray, array( '__DAY__' => (string) $tmp['mday'], - '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), - '__DAY_TEXT_SHORT__' => $outputlangs->trans('Short'.$tmp['weekday']), - '__DAY_TEXT_MIN__' => $outputlangs->trans($tmp['weekday'].'Min'), + '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday + '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon + '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M '__MONTH__' => (string) $tmp['mon'], - '__MONTH_TEXT__' => $outputlangs->trans($tmp['month']), - '__MONTH_TEXT_MIN__' => $outputlangs->trans($tmp['month'].'Min'), + '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])), + '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])), + '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])), '__YEAR__' => (string) $tmp['year'], '__PREVIOUS_DAY__' => (string) $tmp2['day'], '__PREVIOUS_MONTH__' => (string) $tmp3['month'], diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 452a9da08c7..4cbbdebbf14 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -52,6 +52,11 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) if ($removephppart) $replacewith=''; $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); + $replacewith='href="php'; + if ($removephppart) $replacewith=''; + $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); + + //$replacewith='...php...'; $replacewith='...php...'; if ($removephppart) $replacewith=''; $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); @@ -89,23 +94,28 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) * * @param string $content Content string * @return void - * @see dolWebsiteReplacementOfLinks for function used to replace content in the backoffice editor context + * @see dolWebsiteReplacementOfLinks for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on */ function dolWebsiteOutput($content) { global $db, $langs, $conf, $user; global $dolibarr_main_url_root, $dolibarr_main_data_root; - dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')'); + dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor') - - if (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server + if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor + { + // We remove the part of content + $content = preg_replace('/.*<\/head>/ims', '', $content); + $content = preg_replace('/^.*]*)*>/ims', '', $content); + $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content); + } + elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server { global $website; @@ -139,7 +149,7 @@ function dolWebsiteOutput($content) // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); } - else // REPLACEMENT OF LINKS When page called from virtual host + else // REPLACEMENT OF LINKS When page called from virtual host { $symlinktomediaexists=1; @@ -536,7 +546,7 @@ function dolSaveMasterFile($filemaster) $mastercontent = ''."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -598,7 +608,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent =''; $tplcontent.= "mycompany->dir_output."/".$original_file));'."\n"; $wrappercontent.= "else print 'Bad value for modulepart or file';\n"; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 05231f7e9d7..d3b5d12d620 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -116,9 +116,9 @@ class pdf_einstein extends ModelePDFCommandes /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index e4ded69fe9c..5c663e61348 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -105,9 +105,9 @@ class pdf_rouget extends ModelePdfExpedition /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 0cfa9fddb5c..f05c19885da 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -107,9 +107,9 @@ class pdf_standard extends ModeleExpenseReport /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 93f4dbe88ca..a823bae2d4b 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -40,9 +40,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures { /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * @var array() Minimum version of PHP required by module. diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 555e2f76ee0..af770999fda 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -117,9 +117,9 @@ class pdf_crabe extends ModelePDFFactures /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * @var bool Situation invoice type diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index f9576a974f1..b67da288ae7 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -107,9 +107,9 @@ class pdf_soleil extends ModelePDFFicheinter /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * Constructor diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 8b8c629c30b..4793ebe7b27 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -108,9 +108,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * Constructor diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index dd1a26c1d4f..d7d6c154881 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -107,9 +107,9 @@ class pdf_baleine extends ModelePDFProjects /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * Constructor diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 425f9ad1b18..7df62bec482 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -56,9 +56,9 @@ class doc_generic_task_odt extends ModelePDFTask { /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * @var array() Minimum version of PHP required by module. diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 6b5bf3fe3a2..e27fc868155 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -39,9 +39,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales { /** * Issuer - * @var Societe + * @var Company object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; /** * @var array() Minimum version of PHP required by module. diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 54009821fff..40b73e4bf7f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -115,7 +115,7 @@ class pdf_azur extends ModelePDFPropales /** * Issuer - * @var Objet societe qui emet + * @var Company object that emits */ public $emetteur; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 243a692eed8..e7d47f67bda 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -106,7 +106,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Issuer - * @var Objet societe qui emet + * @var Company object that emits */ public $emetteur; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 1be46ee2eca..8478fd70e89 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -110,7 +110,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Issuer - * @var Objet societe qui emet + * @var Company object that emits */ public $emetteur; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index ac69176b1c1..cae6501de2d 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -42,9 +42,9 @@ class doc_generic_user_odt extends ModelePDFUser public $emetteur; /** - * @var array() Minimum version of PHP required by module. + * @var array() Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) - */ + */ public $phpmin = array(5, 4); /** diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 53e42d46832..98ccba8ce21 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -44,9 +44,9 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup public $emetteur; /** - * @var array() Minimum version of PHP required by module. + * @var array() Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) - */ + */ public $phpmin = array(5, 4); /** diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index baf2a66c399..8ca6b6f215a 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -38,15 +38,18 @@ if (empty($module)) $module='ecm'; $permtoadd = 0; $permtoupload = 0; +$showroot = 0; if ($module == 'ecm') { $permtoadd = $user->rights->ecm->setup; $permtoupload = $user->rights->ecm->upload; + $showroot = 0; } if ($module == 'medias') { $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); + $showroot = 1; } @@ -69,29 +72,25 @@ if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->us print '
'; // Toolbar -//if (preg_match('/\/ecm/', $_SERVER['PHP_SELF'])) { -//if ($module == 'ecm') { - - if ($permtoadd) - { - print ''; - print ''; - print ''; - } - else - { - print ''; - print ''; - print ''; - } - if ($module == 'ecm') - { - $tmpurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); - print ''; - print ''; - print ''; - } -//} +if ($permtoadd) +{ + print ''; + print ''; + print ''; +} +else +{ + print ''; + print ''; + print ''; +} +if ($module == 'ecm') +{ + $tmpurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); + print ''; + print ''; + print ''; +} // Start "Add new file" area $nameforformuserfile = 'formuserfileecm'; @@ -148,7 +147,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg print ''."\n"; print ''."\n"; - print ''; + print ''; print ' '.$langs->trans("ECMSections"); print ''; @@ -159,9 +158,17 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { - print ''; + // Show the link to "Root" + if ($showroot) + { + print '
'.$langs->trans("Root").'
'; + } - // Show filemanager tree (will be filled by call of ajax enablefiletreeajax.tpl.php that execute ajaxdirtree.php) + + + print ''; + + // Show filemanager tree (will be filled by call of ajax /ecm/tpl/enablefiletreeajax.tpl.php that execute ajaxdirtree.php) print '
'; if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); @@ -170,7 +177,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg } else { - print ''; + print ''; $_POST['modulepart'] = $module; $_POST['openeddir'] = GETPOST('openeddir'); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 5cfb09946e5..f3367d3e90f 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -213,7 +213,9 @@ if ($forgetpasslink || $helpcenterlink) echo '
'; echo '
'; if ($forgetpasslink) { - echo ''; + $url=DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam; + if (! empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url=$conf->global->MAIN_PASSWORD_FORGOTLINK; + echo ''; echo $langs->trans('PasswordForgotten'); echo ''; } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 46b1f955177..3ed3a92cb50 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,11 @@ /** * \file htdocs/core/website.inc.php * \brief Common file loaded used by all website pages (after master.inc.php) - * The global variable $website must be defined. + * The global variable $websitekey must be defined. */ - include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; $website=new Website($db); $website->fetch(0,$websitekey); + +include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 0a51e8cc73d..b7c20e33d2d 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -27,7 +27,7 @@ if (empty($conf) || ! is_object($conf)) ?> - + "; - print $out; /*file_put_contents($filetpl, $out);