diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index dc995a4f88b..4c1b49d75e6 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -48,9 +48,11 @@ $MAXAGENDA=$conf->global->AGENDA_EXT_NB; // List of aviable colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); + /* * Actions */ + if ($actionsave) { $db->begin(); diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 4e81f0fb1ef..c533ea94795 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -631,7 +631,7 @@ print "\n"; print " ".$langs->trans("Name")."\n"; print " ".$langs->trans("Value")."\n"; print "\n"; -print "\n ".$langs->trans("PathDirectory")."\n ".$conf->propal->dir_output."\n\n"; +print "\n ".$langs->trans("PathDirectory")."\n ".$conf->propal->multidir_output[$conf->entity]."\n\n"; print "\n
"; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index bc328e951d4..f415ed1692c 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -86,7 +86,7 @@ if (! empty($conf->syslog->enabled)) $filelogparam=$filelog; if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam =''.$filelog.''; } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d5b30d67d11..07f124741fe 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -306,7 +306,7 @@ class Documents extends DolibarrApi throw new RestException(404, 'Proposal not found'); } - $upload_dir = $conf->propal->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); + $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); } else if ($modulepart == 'commande' || $modulepart == 'order') { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3dc3ade52e5..3d41aba340a 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -667,11 +667,12 @@ class BlockedLog return -2; } - if (empty($this->action) || empty($this->fk_user) || empty($this->user_fullname)) { + if (empty($this->action)) { $this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); dol_syslog($this->error, LOG_WARNING); return -3; } + if (empty($this->fk_user)) $this->user_fullname='(Anonymous)'; $this->date_creation = dol_now(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ed0950826b8..f0bb9f92e22 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -212,7 +212,7 @@ class ActionComm extends CommonObject $now=dol_now(); // Check parameters - if (empty($this->userownerid)) + if (! isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 { dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); $this->errors[]='ErrorPropertyUserowneridNotDefined'; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4c675b2ca50..fb8154e76ba 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -559,7 +559,7 @@ if ($object->id > 0) // Lien recap $boxstat.='
'; - $boxstat.=''; + $boxstat.='
'; $boxstat.=''; print '
'; if (! empty($conf->propal->enabled)) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 91004c86f67..bdf92b31905 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -676,8 +676,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); - $sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= ", s.code_client"; + $sql = "SELECT s.nom as name, s.rowid, s.code_client"; + $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -726,7 +726,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index db19e943b4b..a8bbb05fb84 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -967,7 +967,7 @@ else * Boutons d'action */ - if (GETPOST('cancel','alpha') || $confirm=='no' || $action == '' || in_array($action,array('settodraft', 'valid','delete','sendall','clone'))) + if (GETPOST('cancel','alpha') || $confirm=='no' || $action == '' || in_array($action,array('settodraft','valid','delete','sendall','clone','test'))) { print "\n\n
\n"; @@ -1071,7 +1071,9 @@ else print '
'; print load_fiche_titre($langs->trans("TestMailing")); - // Create l'objet formulaire mail + dol_fiche_head(null, '', '', -1); + + // Create l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->fromname = $object->email_from; @@ -1099,6 +1101,10 @@ else print $formmail->get_form(); print '
'; + + dol_fiche_end(); + + print dol_set_focus('#sendto'); } @@ -1114,7 +1120,7 @@ else dol_fiche_head('', '', '', -1); - print ''; + print '
'; // Subject print ''; @@ -1260,7 +1266,7 @@ else dol_fiche_head(null, '', '', -1); - print '
'.$langs->trans("MailTopic").''.$object->sujet.'
'; + print '
'; // Subject print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 57af9f5c601..48949881659 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -260,7 +260,7 @@ if ($object->fetch($id) >= 0) print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''), 'title_generic'); //print '
'.$langs->trans("MailTopic").'
'; - print '
'; + print '
'; //print '
'; print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1b685825a13..2e9c184dd11 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1292,7 +1292,7 @@ if (empty($reshook)) } // Actions to build doc - $upload_dir = $conf->propal->dir_output; + $upload_dir = $conf->propal->multidir_output[$object->entity]; $permissioncreate=$user->rights->propal->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -1912,7 +1912,7 @@ if ($action == 'create') print ''; } else { if ($object->date) { - print dol_print_date($object->date, 'daytext'); + print dol_print_date($object->date, 'day'); } else { print ' '; } @@ -1938,7 +1938,7 @@ if ($action == 'create') print ''; } else { if (! empty($object->fin_validite)) { - print dol_print_date($object->fin_validite, 'daytext'); + print dol_print_date($object->fin_validite, 'day'); if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); } else { @@ -2416,7 +2416,7 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->propal->lire; $delallowed = $user->rights->propal->creer; @@ -2457,7 +2457,7 @@ if ($action == 'create') // Presend form $modelmail='propal_send'; $defaulttopic='SendPropalRef'; - $diroutput = $conf->propal->dir_output; + $diroutput = $conf->propal->multidir_output[$object->entity]; $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 850fa969bbb..3adc58ecbae 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1749,8 +1749,8 @@ class Propal extends CommonObject // to not lose the linked files $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->propal->dir_output.'/'.$oldref; - $dirdest = $conf->propal->dir_output.'/'.$newref; + $dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref; if (file_exists($dirsource)) { @@ -1759,7 +1759,7 @@ class Propal extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + $listoffiles=dol_dir_list($dirdest, 'files', 1, '^'.preg_quote($oldref,'/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; @@ -2815,9 +2815,9 @@ class Propal extends CommonObject { // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->propal->dir_output && !empty($this->ref)) + if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->propal->dir_output . "/" . $ref ; + $dir = $conf->propal->multidir_output[$this->entity] . "/" . $ref ; $file = $dir . "/" . $ref . ".pdf"; if (file_exists($file)) { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index ba373c78f44..4ceae6b1221 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -75,7 +75,7 @@ $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; } @@ -90,7 +90,7 @@ $form = new Form($db); if ($object->id > 0) { - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = propal_prepare_head($object); dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal'); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index a313ab299f0..e9dce10ea0b 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -216,7 +216,7 @@ $max=5; * Last modified proposals */ -$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; +$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; $sql.= " date_cloture as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -262,7 +262,7 @@ if ($resql) print '
'; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; @@ -296,7 +296,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $now=dol_now(); - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; + $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -341,7 +342,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print ''; print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index a47625e100b..cdcd5bf014b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -110,7 +110,7 @@ if (! empty($socid)) } $result = restrictedArea($user, $module, $objectid, $dbtable); -$diroutputmassaction=$conf->propal->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('propallist')); @@ -214,7 +214,7 @@ if (empty($reshook)) $objectlabel='Proposals'; $permtoread = $user->rights->propal->lire; $permtodelete = $user->rights->propal->supprimer; - $uploaddir = $conf->propal->dir_output; + $uploaddir = $conf->propal->multidir_output[$conf->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -242,7 +242,7 @@ if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -462,7 +462,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -663,7 +663,7 @@ if ($resql) // Other picto tool print '
'; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 92e04e1672b..5cf5b6c7b40 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4067,7 +4067,7 @@ class OrderLine extends CommonOrderLine $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").','; $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$this->fk_multicurrency; + $sql.= ", ".(! empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL'); $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".$this->multicurrency_subprice; $sql.= ", ".$this->multicurrency_total_ht; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 692df2fcb22..91e496d998c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -73,16 +73,16 @@ $description=GETPOST("description",'alpha'); $dateop = dol_mktime(12,0,0,GETPOST("opmonth",'int'),GETPOST("opday",'int'),GETPOST("opyear",'int')); $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); -$type=GETPOST("type",'alpha'); -$account=GETPOST("account",'int'); -$accountancy_code=GETPOST('accountancy_code', 'alpha'); -$bid=GETPOST("bid","int"); +$search_type=GETPOST("search_type",'alpha'); +$search_account=GETPOST("search_account",'int')?GETPOST("search_account",'int'):GETPOST("account",'int'); +$search_accountancy_code=GETPOST('search_accountancy_code', 'alpha')?GETPOST('search_accountancy_code', 'alpha'):GETPOST('accountancy_code', 'alpha'); +$search_bid=GETPOST("search_bid","int")?GETPOST("search_bid","int"):GETPOST("bid","int"); $search_ref=GETPOST('search_ref','alpha'); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); $search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int')); -$search_thirdparty=GETPOST("thirdparty",'alpha'); +$search_thirdparty=GETPOST("search_thirdparty",'alpha')?GETPOST("search_thirdparty",'alpha'):GETPOST("thirdparty",'alpha'); $search_req_nb=GETPOST("req_nb",'alpha'); $search_num_releve=GETPOST("search_num_releve",'alpha'); $search_conciliated=GETPOST("search_conciliated",'int'); @@ -108,7 +108,7 @@ $mode_balance_ok=false; if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) { $sortfield = 'b.datev,b.dateo,b.rowid'; - if ($id > 0 || ! empty($ref) || $account > 0) $mode_balance_ok = true; + if ($id > 0 || ! empty($ref) || $search_account > 0) $mode_balance_ok = true; } if (strtolower($sortorder) == 'desc') $mode_balance_ok = false; @@ -116,7 +116,7 @@ $object = new Account($db); if ($id > 0 || ! empty($ref)) { $result=$object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + $search_account = $object->id; // Force the search field on id of account } @@ -179,10 +179,10 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_dv_start=''; $search_dv_end=''; $description=""; - $type=""; + $search_type=""; $debit=""; $credit=""; - $bid=""; + $search_bid=""; $search_ref=""; $search_req_nb=''; $search_thirdparty=''; @@ -190,8 +190,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_conciliated=''; $thirdparty=''; - $account=""; - if ($id > 0 || ! empty($ref)) $account=$object->id; + $search_account=""; + if ($id > 0 || ! empty($ref)) $search_account=$object->id; } if (empty($reshook)) @@ -297,7 +297,7 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); } - /*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) + /*if (! empty($conf->accounting->enabled) && (empty($search_accountancy_code) || $search_accountancy_code == '-1')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); $error++; @@ -307,7 +307,7 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) { $objecttmp = new Account($db); $objecttmp->fetch($bankaccountid); - $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); + $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $search_accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -364,26 +364,27 @@ $now = dol_now(); // Must be before button action $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($id > 0) $param.='&id='.urlencode($id); if (!empty($ref)) $param.='&ref='.urlencode($ref); if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref); if (!empty($description)) $param.='&description='.urlencode($description); -if (!empty($type)) $param.='&type='.urlencode($type); -if (!empty($debit)) $param.='&debit='.$debit; -if (!empty($credit)) $param.='&credit='.$credit; -if (!empty($account)) $param.='&account='.$account; +if (!empty($search_type)) $param.='&type='.urlencode($search_type); +if (!empty($search_thirdparty)) $param.='&search_thirdparty='.urlencode($search_thirdparty); +if (!empty($debit)) $param.='&debit='.urlencode($debit); +if (!empty($credit)) $param.='&credit='.urlencode($credit); +if (!empty($search_account)) $param.='&search_account='.urlencode($search_account); if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); if ($search_conciliated != '' && $search_conciliated != '-1') $param.='&search_conciliated='.urlencode($search_conciliated); -if (!empty($bid)) $param.='&bid='.$bid; +if ($search_bid > 0) $param.='&search_bid='.urlencode($search_bid); if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPOST('search_start_dvmonth', 'int') . '&search_start_dvday=' . GETPOST('search_start_dvday', 'int') . '&search_start_dvyear=' . GETPOST('search_start_dvyear', 'int'); if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); -if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); -if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); +if (GETPOST("search_thirdparty",'int')) $param.='&thirdparty='.urlencode(GETPOST("search_thirdparty",'int')); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -454,7 +455,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM "; -if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +if ($search_bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_extrafields as ef on (b.rowid = ef.fk_object)"; @@ -462,21 +463,21 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -if ($account > 0) $sql.=" AND b.fk_account = ".$account; +if ($search_account > 0) $sql.=" AND b.fk_account = ".$search_account; // Search period criteria if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; // Search period criteria if (dol_strlen($search_dv_start)>0) $sql .= " AND b.datev >= '" . $db->idate($search_dv_start) . "'"; if (dol_strlen($search_dv_end)>0) $sql .= " AND b.datev <= '" . $db->idate($search_dv_end) . "'"; -if ($search_ref) $sql.=natural_search("b.rowid", $search_ref); +if ($search_ref) $sql.=natural_search("b.rowid", $search_ref, 1); if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve); if ($search_conciliated != '' && $search_conciliated != '-1') $sql.= " AND b.rappro = ".$search_conciliated; if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty); if ($description) $sql.= natural_search("b.label", $description); // Warning some text are just translation keys, not translated strings -if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; -if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' "; +if ($search_bid > 0) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; +if (! empty($search_type)) $sql.= " AND b.fk_type = '".$db->escape($search_type)."' "; // Search criteria amount $debit = price2num(str_replace('-','',$debit)); $credit = price2num(str_replace('-','',$credit)); @@ -518,11 +519,11 @@ if ($page >= $nbtotalofpages) } // If not account defined $mode_balance_ok=false -if (empty($account)) $mode_balance_ok=false; +if (empty($search_account)) $mode_balance_ok=false; // If a search is done $mode_balance_ok=false if (! empty($search_ref)) $mode_balance_ok=false; if (! empty($req_nb)) $mode_balance_ok=false; -if (! empty($type)) $mode_balance_ok=false; +if (! empty($search_type)) $mode_balance_ok=false; if (! empty($debit)) $mode_balance_ok=false; if (! empty($credit)) $mode_balance_ok=false; if (! empty($thirdparty)) $mode_balance_ok=false; @@ -643,7 +644,7 @@ if ($resql) print ' '; print ''.$langs->trans("Type").''; print ''.$langs->trans("Numero").''; - //if (! $account > 0) + //if (! $search_account > 0) //{ print ''.$langs->trans("BankAccount").''; //} @@ -677,10 +678,10 @@ if ($resql) print ''; print ''; print ''; - //if (! $account > 0) + //if (! $search_account > 0) //{ print ''; - $form->select_comptes(GETPOST('add_account','int')?GETPOST('add_account','int'):$account,'add_account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + $form->select_comptes(GETPOST('add_account','int')?GETPOST('add_account','int'):$search_account,'add_account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); print ''; //} print ''; @@ -688,7 +689,7 @@ if ($resql) /*if (! empty($conf->accounting->enabled)) { print ''; - print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, null, 1, 1, ''); print ''; }*/ print ''; @@ -733,7 +734,7 @@ if ($resql) if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments { if ($user->rights->banque->modifier) { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $addbutton = ''.$langs->trans("AddBankRecord").''; } else { $addbutton = ''.$langs->trans("AddBankRecord").''; } @@ -768,15 +769,8 @@ if ($resql) $picto='title_bank'; if ($id > 0 || ! empty($ref)) $picto=''; - if (GETPOST("bid")) - { - $result=$bankcateg->fetch(GETPOST("bid")); - print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); - } - else - { - print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); - } + + print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); // We can add page now to param if ($page != '') $param.='&page='.urlencode($page); @@ -799,6 +793,22 @@ if ($resql) $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; + if (! empty($conf->categorie->enabled)) + { + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + { + $langs->load('categories'); + + // Bank line + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('RubriquesTransactions').' : '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1); + $moreforfilter.=$form->selectarray('search_bid', $cate_arbo, $search_bid, 1); + $moreforfilter.='
'; + } + } + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; @@ -842,7 +852,7 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) { print ''; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 0, 1, 'maxwidth100'); + $form->select_types_paiements(empty($search_type)?'':$search_type, 'search_type', '', 2, 0, 1, 0, 1, 'maxwidth100'); print ''; } if (! empty($arrayfields['b.num_chq']['checked'])) @@ -852,12 +862,12 @@ if ($resql) } if (! empty($arrayfields['bu.label']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['ba.ref']['checked'])) { print ''; - $form->select_comptes($account,'account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + $form->select_comptes($search_account,'search_account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); print ''; } if (! empty($arrayfields['b.debit']['checked'])) @@ -947,7 +957,7 @@ if ($resql) // If we are in a situation where we need/can show balance, we calculate the start of balance if (! $balancecalculated && (! empty($arrayfields['balancebefore']['checked']) || ! empty($arrayfields['balance']['checked'])) && $mode_balance_ok) { - if (! $account) + if (! $search_account) { dol_print_error('', 'account is not defined but $mode_balance_ok is true'); exit; @@ -962,7 +972,7 @@ if ($resql) $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b"; $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sqlforbalance.= " AND b.fk_account = ".$account; + $sqlforbalance.= " AND b.fk_account = ".$search_account; $sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $resqlforbalance = $db->query($sqlforbalance); //print $sqlforbalance; @@ -1048,7 +1058,7 @@ if ($resql) if (! empty($arrayfields['b.rowid']['checked'])) { print ''; - print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; + print "rowid.'&save_lastsearch_values=1">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index e1b5af4e88d..8d955f1141d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1189,7 +1189,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "\n"; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 0966807facd..6cd80d8dff6 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -599,8 +599,10 @@ if ($resql) if (! empty($arrayfields['f.date_when']['checked'])) { print ''; + print '
'; print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + print '
'; print ''; if (! $i) $totalarray['nbfield']++; } @@ -636,7 +638,7 @@ if ($resql) } else { - print $langs->trans("DateIsNotEnough"); + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); } } else diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 570942590c2..79a88d11c4d 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -132,7 +132,7 @@ class Localtax extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user=null, $notrigger=0) + function update(User $user, $notrigger=0) { global $conf, $langs; @@ -149,8 +149,8 @@ class Localtax extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET"; - $sql.= " localtaxtype=".$this->ltt.","; + $sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET"; + $sql.= " localtaxtype=".$this->ltt.","; $sql.= " tms='".$this->db->idate($this->tms)."',"; $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; @@ -160,7 +160,7 @@ class Localtax extends CommonObject $sql.= " fk_bank=".$this->fk_bank.","; $sql.= " fk_user_creat=".$this->fk_user_creat.","; $sql.= " fk_user_modif=".$this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -255,12 +255,12 @@ class Localtax extends CommonObject } - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ function delete($user) { // Call trigger @@ -285,11 +285,11 @@ class Localtax extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ function initAsSpecimen() { diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 11751fe258b..4f17a4444f5 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -88,11 +88,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); $paiement_id = 0; $totalpayment = 0; $multicurrency_totalpayment = 0; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index c684e041660..8a165ebe811 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -564,7 +564,7 @@ else $accountstatic=new Account($db); $accountstatic->fetch($object->account_id); - $linkback=''.$langs->trans("BackToList").''; + $linkback=''.$langs->trans("BackToList").''; $morehtmlref=''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 3458e6bc82a..528b01477a6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -979,25 +979,56 @@ class RemiseCheque extends CommonObject } /** - * Return clicable name (with picto eventually) + * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option Sur quoi pointe le lien - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option Sur quoi pointe le lien + * @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 Chaine avec URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { - global $langs; + global $conf, $langs; $result=''; - $label = $langs->trans("ShowCheckReceipt").': '.$this->ref; - $link = ''; + $label = ''.$langs->trans("ShowCheckReceipt").''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/compta/paiement/cheque/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("ShowCheckReceipt"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = '
'; $linkend=''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.$this->ref.$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; return $result; } diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index e9f887e37f4..9ddbd0b5cf6 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -92,10 +92,12 @@ print '
'; $max=10; -$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref"; -$sql.= ", bc.statut, bc.nbcheque"; -$sql.= ", ba.label, ba.rowid as bid"; +$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; +$sql.= " bc.statut, bc.nbcheque,"; +$sql.= " ba.ref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.accountancy_journal,"; +$sql.= " aj.code"; $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; $sql.= " WHERE ba.rowid = bc.fk_bank_account"; $sql.= " AND bc.entity = ".$conf->entity; $sql.= " ORDER BY bc.date_bordereau DESC, rowid DESC"; @@ -122,8 +124,13 @@ if ($resql) $checkdepositstatic->statut=$objp->statut; $accountstatic->id=$objp->bid; + $accountstatic->ref=$objp->ref; $accountstatic->label=$objp->label; - + $accountstatic->number=$objp->number; + $accountstatic->currency_code=$objp->currency_code; + $accountstatic->account_number=$objp->account_number; + $accountstatic->accountancy_journal=$objp->code; + print ''."\n"; print ''.$checkdepositstatic->getNomUrl(1).''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 42106c1cb13..4d23637dfe7 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -209,9 +209,10 @@ class Paiement extends CommonObject $total = $totalamount_converted; // Maybe use price2num with MT for the converted value $mtotal = $totalamount; } + $note = ($this->note_public?$this->note_public:$this->note); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)"; - $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; + $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', ".$user->id.")"; dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/tovalidate.php similarity index 96% rename from htdocs/compta/paiement/avalider.php rename to htdocs/compta/paiement/tovalidate.php index beb2fb77ecd..7e16b525233 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -17,9 +17,9 @@ */ /** - * \file htdocs/compta/paiement/avalider.php + * \file htdocs/compta/paiement/tovalidate.php * \ingroup compta - * \brief Page liste des paiements a valider des factures clients + * \brief Page list payment to validate. Visible in menu when option BILL_ADD_PAYMENT_VALIDATION is on. */ require '../../main.inc.php'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4600baf56ed..a2d189c9790 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1926,7 +1926,7 @@ else print $langs->trans("DateEndReal").': '; print dol_print_date($objp->date_fin_reelle, 'day'); } - if (! empty($objp->comment)) print "
".$objp->comment; + if (! empty($objp->comment)) print "  -  ".$objp->comment; print ''; print ' '; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 64050c3512d..1b81d9d13f6 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -49,8 +49,13 @@ $result=restrictedArea($user,'contrat',$id); $object = new Contrat($db); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('contractcard','globalcard')); -// Add new contact + +/* + * Actions + */ if ($action == 'addcontact' && $user->rights->contrat->creer) { diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 32fcd5a64bd..4bc2747a829 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -77,10 +77,14 @@ if ($object->id > 0) $upload_dir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart='contract'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('contractcard','globalcard')); + /* * Actions */ + include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php index 10f31ac1612..b6c92eac27e 100644 --- a/htdocs/contrat/info.php +++ b/htdocs/contrat/info.php @@ -41,6 +41,17 @@ $ref = GETPOST('ref','alpha'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contrat', $id, ''); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('contractcard','globalcard')); + + +/* + * Actions + */ + +// None + + /* * View diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index babc31f7702..94118d415bf 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -487,13 +487,13 @@ if ($resql) if (! empty($arrayfields['c.date_contrat']['checked'])) { // Date contract - print ''; + print ''; //print $langs->trans('Month').': '; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; - $formother->select_year($syear,'year',1, 20, 5); + print $formother->selectyear($syear,'year',1, 20, 5, 0, 0, '', 'widthauto'); print ''; } // Extra fields diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 9a6d28dd4c9..ab76d9aaec3 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -49,6 +49,10 @@ $object->fetch($id,$ref); $permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('contractcard','globalcard')); + + /* * Actions diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 8b5bfbc817d..d665d70da56 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -91,6 +91,8 @@ class box_graph_invoices_permonth extends ModeleBoxes if ($user->rights->facture->lire) { + $mesg = ''; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -246,13 +248,11 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow.='
'; $stringtoshow.='
'; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', - 'maxlength'=>500, - 'text' => $mesg); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="left" class="nohover"', 'maxlength'=>500, 'text' => $mesg); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 436343a56dc..efd7de41e5a 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -245,11 +245,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; $stringtoshow.=''; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"','td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="left" class="nohover"', 'maxlength'=>500, 'text' => $mesg); } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 7e60e00a2fc..699f2db902b 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -244,11 +244,11 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow.=''; $stringtoshow.=''; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="left" class="nohover"', 'maxlength'=>500, 'text' => $mesg); } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 6f8ebf39001..f49f38c1228 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -243,11 +243,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow.=''; $stringtoshow.=''; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="left" class="nohover"', 'maxlength'=>500, 'text' => $mesg); } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index bac56d8006b..69a09e8aad2 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -386,7 +386,7 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.=$px3->show(); $stringtoshow.=''; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 690df3d41fa..50e3cbe9bf8 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -245,11 +245,11 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow.=''; $stringtoshow.=''; } - $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="left" class="nohover"', 'maxlength'=>500, 'text' => $mesg); } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f5a16aa540b..a4ea3a70447 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -319,7 +319,7 @@ abstract class CommonDocGenerator foreach($conf->global as $key => $val) { - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; else $newval = $val; $array_other['__['.$key.']__'] = $newval; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d08d5df3f78..89647c4a9e6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2739,7 +2739,7 @@ abstract class CommonObject * @param string $targettype Object target type (if not defined, elemennt name of object) * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. - * @return void + * @return int <0 if KO, >0 if OK * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1) @@ -2920,10 +2920,12 @@ abstract class CommonObject } } } + return 1; } else { dol_print_error($this->db); + return -1; } } @@ -3057,6 +3059,7 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'mailing') $fieldstatus="statut"; + if ($elementTable == 'cronjob') $fieldstatus="status"; if ($elementTable == 'user') $fieldstatus="statut"; if ($elementTable == 'expensereport') $fieldstatus="fk_statut"; if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; @@ -3581,7 +3584,7 @@ abstract class CommonObject * Return HTML table for object lines * TODO Move this into an output class file (htmlline.class.php) * If lines are into a template, title must also be into a template - * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. + * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * * @param string $action Action code * @param string $seller Object of seller third party @@ -4519,10 +4522,11 @@ abstract class CommonObject { $extrafields->fetch_name_optionals_label($this->table_element); } - $optionsArray = $extrafields->attributes[$this->table_element]['label']; + $optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null); } else { + global $extrafields; dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING); } @@ -4696,7 +4700,8 @@ abstract class CommonObject if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) { // If there is an encryption choice, we use it to crypt data before insert - $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + $tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']); + $algo=reset($tmparrays); if ($algo != '') { //global $action; // $action may be 'create', 'update', 'update_extras'... diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a1d051440c3..0705d2fd60d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -310,7 +310,7 @@ class Conf // For user storage $this->user->multidir_output = array($this->entity => $rootfordata."/users"); - $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); + $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); // For backward compatibility $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; @@ -320,6 +320,9 @@ class Conf $this->usergroup->dir_temp=$rootforuser."/usergroups/temp"; // For propal storage + $this->propal->multidir_output = array($this->entity => $rootfordata."/propale"); + $this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp"); + // For backward compatibility $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 08d6c3bfeaf..861848e6924 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -235,6 +235,7 @@ class ExtraFields $lengthdb='11'; } elseif ($type=='html') { $typedb='text'; + $lengthdb=$length; } elseif($type=='password') { $typedb='varchar'; $lengthdb='128'; @@ -742,7 +743,7 @@ class ExtraFields dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed"; - $sql .= ",entity"; + $sql.= ",entity"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a98729ac055..fdd1aaa5a76 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3426,7 +3426,8 @@ class Form } else { - print $langs->trans("NoActiveBankAccountDefined"); + if ($statut == 0) print $langs->trans("NoActiveBankAccountDefined"); + else print $langs->trans("NoBankAccountFound"); } } else { diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2d66661c839..f254fe44b9d 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -194,6 +194,7 @@ class FormActions $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; + $buttontoaddnewevent=''; if (! empty($conf->agenda->enabled)) { $buttontoaddnewevent = ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index b139483b610..077a29d4595 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -299,6 +299,9 @@ class FormFile return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } + // Add entity in $param + $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + $printer=0; if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport'))) // The direct print feature is implemented only for such elements { @@ -699,7 +702,8 @@ class FormFile $out.= ''."\n"; // Show title of array if not already shown - if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) + if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) + && ! $headershown) { $headershown=1; $out.= '
'.$titletoshow.'
'."\n"; @@ -744,7 +748,7 @@ class FormFile if ($delallowed || $printer || $morepicto) { - $out.= ''; + $out.= ''; if ($delallowed) { $out.= '
withsubstit)) // Unset or set ->withsubstit=0 to disable this. diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3339b2b054e..de87e6c2e39 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -881,9 +881,10 @@ class FormOther * @param int $offset Offset * @param int $invert Invert * @param string $option Option + * @param string $morecss More css * @return string */ - function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='') { $out=''; @@ -892,7 +893,7 @@ class FormOther $min_year = $currentyear-$min_year; if(empty($selected) && empty($useempty)) $selected = $currentyear; - $out.= ''; if($useempty) { $selected_html=''; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index e7cd6d447a0..86e0f48c65f 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -164,7 +164,7 @@ class FormWebsite * * @param string $htmlname Name of select zone * @param string $selected Selected value - * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param int $useempty 1=Add an empty value in list * @param string $moreattrib More attributes on HTML select tag * @return void */ @@ -177,9 +177,9 @@ class FormWebsite $arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage'); $out = ''; - $out .= '"; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 7554a82a5fd..cff29099743 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -392,13 +392,13 @@ class Notify break; case 'PROPAL_VALIDATE': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; case 'PROPAL_CLOSE_SIGNED': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); break; @@ -574,13 +574,13 @@ class Notify break; case 'PROPAL_VALIDATE': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; case 'PROPAL_CLOSE_SIGNED': $link='/comm/propal/card.php?id='.$object->id; - $dir_output = $conf->propal->dir_output; + $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); break; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 4502eb03240..7d5f742a779 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -67,7 +67,7 @@ class Utils // Delete temporary files if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$','','','',2); + $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2, 0, '', 1); // Do not follow symlinks if ($choice == 'tempfilesold') { $now = dol_now(); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index fcc3098c730..0f219a032cc 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1288,9 +1288,10 @@ function complete_elementList_with_modules(&$elementList) $modules[$i] = $objMod; $filename[$i]= $modName; - $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module + $orders[$i] = $objMod->family."_".$j; // Sort on family then module number + $dirmod[$i] = $dir; //print "x".$modName." ".$orders[$i]."\n
"; - $dirmod[$i] = $dirroot; + if (! empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 529f58dbbf1..103b106b008 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -52,10 +52,11 @@ function dol_basename($pathfile) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks * @param string $relativename For recursive purpose only. Must be "" at first call. + * @param string $donotfollowsymlinks Do not follow symbolic links * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list_indatabase */ -function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="") +function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0) { global $db, $hookmanager; global $object; @@ -159,7 +160,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file)); + if (empty($donotfollowsymlinks) || ! is_link($path."/".$file)) + { + //var_dump('eee '. $path."/".$file. ' '.is_dir($path."/".$file).' '.is_link($path."/".$file)); + $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks)); + } } } else if (! $isdir && (($types == "files") || ($types == "all"))) @@ -2147,10 +2152,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->facture->dir_output.'/'.$original_file; } // Wrapping pour les apercu propal - elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output)) + elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->dir_output.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les apercu commande elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output)) @@ -2195,10 +2200,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->expensereport->dir_output.'/'.$original_file; } // Wrapping pour les images des stats propales - elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) + elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->dir_temp.'/'.$original_file; + $original_file=$conf->propal->multidir_temp[$entity].'/'.$original_file; } // Wrapping pour les images des stats commandes elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) @@ -2362,13 +2367,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping for mass actions - else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } - $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; } else if ($modulepart == 'massfilesarea_orders') { @@ -2402,7 +2407,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } - else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output)) { if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file)) { @@ -2457,14 +2462,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping pour les propales - else if ($modulepart == 'propal' && !empty($conf->propal->dir_output)) + else if ($modulepart == 'propal' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } - - $original_file=$conf->propal->dir_output.'/'.$original_file; + $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 78bd6caa2b6..4a9d4e6bc5e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7108,7 +7108,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='' if ($alldata == 1) { - if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), ); + if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:''), 'mime'=>dol_mimetype($relativepath), ); else return array(); } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index f0d42888745..c50661de831 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -35,7 +35,7 @@ function propal_prepare_head($object) $langs->load("propal"); $langs->load("compta"); $langs->load("companies"); - + $h = 0; $head = array(); @@ -86,7 +86,7 @@ function propal_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 82e9a98d43f..50716c27aca 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -177,6 +177,7 @@ function redirectToContainer($containerref, $containeraliasalt='',$containerid=0 global $db, $website; $newurl = ''; + $result=0; // We make redirect using the alternative alias, we must find the real $containerref if ($containeraliasalt) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1237b72f826..000c228ef8e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -818,7 +818,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - $newmenu->add("/compta/paiement/avalider.php?leftmenu=customers_bills_tovalid",$langs->trans("MenuToValid"),2,$user->rights->facture->lire,'',$mainmenu,'customer_bills_tovalid'); + $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid",$langs->trans("MenuToValid"),2,$user->rights->facture->lire,'',$mainmenu,'customer_bills_tovalid'); } $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_reports",$langs->trans("Reportings"),2,$user->rights->facture->lire,'',$mainmenu,'customers_bills_reports'); diff --git a/htdocs/core/modules/dons/html_cerfafr.html b/htdocs/core/modules/dons/html_cerfafr.html index bd066d73a05..614f22cf998 100644 --- a/htdocs/core/modules/dons/html_cerfafr.html +++ b/htdocs/core/modules/dons/html_cerfafr.html @@ -72,7 +72,7 @@ Fondation d'entreprise - + Oeuvre ou organisme d'intérêt général diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 0f7f2aa2c36..c9d2b4984ad 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2006 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2012 Marcos García - * Copyright (C) 2014-2015 Alexandre Spangaro + * Copyright (C) 2014-2015 Alexandre Spangaro * Copyright (C) 2015 Benoit Bruchard * * This program is free software; you can redistribute it and/or modify @@ -89,7 +89,7 @@ class html_cerfafr extends ModeleDon $outputlangs->load("donations"); $currency = !empty($currency) ? $currency : $conf->currency; - + if (! empty($conf->don->dir_output)) { // Definition of the object don (for upward compatibility) @@ -134,21 +134,21 @@ class html_cerfafr extends ModeleDon $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; } else $paymentmode = ''; - - if ($don->modepaiementid==7){ + + if ($don->modepaymentcode=='CHQ'){ $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } - else if ($don->modepaiementid==4){ + else if ($don->modepaymentcode=='LIQ'){ $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } - else if ($don->modepaiementid==2 || $don->modepaiementid==3 || $don->modepaiementid==6){ + else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; - } - else + } + else { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } - + /* if (empty($don->societe)) { @@ -159,14 +159,14 @@ class html_cerfafr extends ModeleDon $CodeDon = ' 200 du CGI 238 bis du CGI 885-0 V bis A du CGI'; } */ - + // Define contents $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__',$don->id,$form); $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist - $form = str_replace('__AMOUNT__',$don->amount,$form); + $form = str_replace('__AMOUNT__', price($don->amount), $form); $form = str_replace('__AMOUNTLETTERS__',chiffre_en_lettre($don->amount),$form); $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form); $form = str_replace('__CURRENCYCODE__',$conf->currency,$form); @@ -183,7 +183,6 @@ class html_cerfafr extends ModeleDon $form = str_replace('__DONATOR_ZIP__',$don->zip,$form); $form = str_replace('__DONATOR_TOWN__',$don->town,$form); $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form); - $form = str_replace('__ModePaiement__', $ModePaiement,$form); $form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form); $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form); $form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form); @@ -204,6 +203,8 @@ class html_cerfafr extends ModeleDon $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form); $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form); + $form = str_replace('__ModePaiement__', $ModePaiement,$form); + $frencharticle=''; if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)'; $form = str_replace('__FrenchArticle__',$frencharticle,$form); @@ -260,7 +261,7 @@ class html_cerfafr extends ModeleDon @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; } else @@ -394,34 +395,34 @@ function chiffre_en_lettre($montant, $devise1='', $devise2='') if($cent[$i]==1) $trio[$i]='cent'; else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; } - - + + $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); $secon_c=$chif2[$dix_c]; if($cent_c==1) $trio_c='cent'; else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; - + if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; else $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; - + if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) $somme = $somme.' mille '; else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; else $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; - + $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; - + $somme = $somme. ' '. $dev1 .' ' ; - + if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) return $somme. ' et zéro '. $dev2; else return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; - + } diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index 3ea0535bd4f..6214d0abb59 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -114,7 +114,7 @@ class modPaypal extends DolibarrModules 'url'=>'/paypal/importpayments.php', 'langs'=>'paypal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>501, - 'enabled'=>'$conf->paypal->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->paypal->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'$user->rights->banque->consolidate', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2 diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index 46af17cee55..fa9abbec0e5 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -100,7 +100,7 @@ class modStripe extends DolibarrModules 'url'=>'/stripe/importpayments.php', 'langs'=>'stripe', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>500, - 'enabled'=>'$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'$user->rights->banque->consolidate', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2 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 bc34d5b5691..0b71e9e862f 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 @@ -246,7 +246,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $outputlangs->load("companies"); $outputlangs->load("bills"); - if ($conf->propal->dir_output) + if ($conf->propal->multidir_output[$conf->entity]) { // If $object is id instead of object if (! is_object($object)) @@ -261,7 +261,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales } } - $dir = $conf->propal->dir_output; + $dir = $conf->propal->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".odt"; @@ -303,7 +303,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales //print "file=".$file; //print "conf->propal->dir_temp=".$conf->propal->dir_temp; - dol_mkdir($conf->propal->dir_temp); + dol_mkdir($conf->propal->multidir_temp[$object->entity]); // If CUSTOMER contact defined on proposal, we use it @@ -357,7 +357,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->propal->dir_temp, + 'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity], 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 7be8b6a0d08..a54cfbf212f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -230,7 +230,7 @@ class pdf_azur extends ModelePDFPropales if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->propal->dir_output) + if ($conf->propal->multidir_output[$conf->entity]) { $object->fetch_thirdparty(); @@ -239,13 +239,13 @@ class pdf_azur extends ModelePDFPropales // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->propal->dir_output; + $dir = $conf->propal->multidir_output[$conf->entity]; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->dir_output . "/" . $objectref; + $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } @@ -1501,7 +1501,7 @@ class pdf_azur extends ModelePDFPropales { $top_shift = $pdf->getY() - $current_y; } - + if ($showaddress) { // Sender properties diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 6ab7fecbf10..23e5aff0cae 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -67,7 +67,7 @@ if ($conf->multicompany->enabled) { print ' '; print "\n"; -if (count($extrafields->attributes[$elementtype]['type'])) +if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { foreach($extrafields->attributes[$elementtype]['type'] as $key => $value) { diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index aa392489987..c700f4d6984 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -60,8 +60,9 @@ $userstatic=new User($db); ?> +
-
+
'."\n"; print '
'."\n"; if ($module != 'product') { // No public note yet on products - print '
'."\n"; + print '
'."\n"; print '
'."\n"; print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); print '
'."\n"; @@ -88,7 +88,7 @@ if ($module != 'product') { print '
'."\n"; } if (empty($user->societe_id)) { - print '
'."\n"; + print '
'."\n"; print '
'."\n"; print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); print '
'."\n"; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 1debc47e776..be5ffbe965d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -63,6 +63,11 @@ class Cronjob extends CommonObject public $libname; public $test; // A test condition to know if job is visible/qualified + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + const STATUS_ARCHIVED = 2; + + /** * Constructor * diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index a73ba1bdd55..f6a695d4a39 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -29,17 +29,18 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; -$langs->load("admin"); -$langs->load("cron"); -$langs->load("bills"); +$langs->loadLangs(array("admin","cron","bills")); if (!$user->rights->cron->read) accessforbidden(); $action=GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search +$id=GETPOST('id','int'); + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -51,8 +52,8 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='t.status,t.priority'; if (! $sortorder) $sortorder='DESC,ASC'; -$status=GETPOST('status','int'); -if ($status == '') $status=-2; +$search_status=GETPOST('search_status','int')?GETPOST('search_status','int'):GETPOST('status','int'); +if ($search_status == '') $search_status=-2; //Search criteria $search_label=GETPOST("search_label",'alpha'); @@ -75,80 +76,129 @@ $object = new Cronjob($db); * Actions */ -// Do we click on 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 -{ - $search_label=''; - $status=-1; -} +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -$filter=array(); -if (!empty($search_label)) -{ - $filter['t.label']=$search_label; -} +$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'); -// Delete jobs -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) +if (empty($reshook)) { - //Delete cron task - $object = new Cronjob($db); - $object->id=$id; - $result = $object->delete($user); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + // 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 + { + $search_label=''; + $search_status=-1; + $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 } -} -// Execute jobs -if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) -{ - if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) - { - setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); - $action=''; - } - else - { - $object = new Cronjob($db); - $job = $object->fetch($id); + $filter=array(); + if (!empty($search_label)) + { + $filter['t.label']=$search_label; + } - $now = dol_now(); // Date we start + // Delete jobs + if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) + { + //Delete cron task + $object = new Cronjob($db); + $object->id=$id; + $result = $object->delete($user); - $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK - if ($resrunjob < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } - // Programm next run - $res = $object->reprogram_jobs($user->login, $now); - if ($res > 0) - { - if ($resrunjob >= 0) // We show the result of reprogram only if no error message already reported - { - if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); - else setEventMessages($langs->trans("JobFinished"), null, 'errors'); - } - $action=''; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } + // Execute jobs + if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) + { + if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) + { + setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); + $action=''; + } + else + { + $object = new Cronjob($db); + $job = $object->fetch($id); - $param='&status='.$status; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_label) $param.='&search_label='.$search_label; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + $now = dol_now(); // Date we start - header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); // Make a redirect to avoid to run twice the job when using back - exit; - } + $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK + if ($resrunjob < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Programm next run + $res = $object->reprogram_jobs($user->login, $now); + if ($res > 0) + { + if ($resrunjob >= 0) // We show the result of reprogram only if no error message already reported + { + if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); + else setEventMessages($langs->trans("JobFinished"), null, 'errors'); + } + $action=''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + + $param='&search_status='.urlencode($search_status); + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_label) $param.='&search_label='.urlencode($search_label); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); // Make a redirect to avoid to run twice the job when using back + exit; + } + } + + // Mass actions + $objectclass='CronJob'; + $objectlabel='CronJob'; + $permtoread = $user->rights->cron->read; + $permtocreate = $user->rights->cron->create?$user->rights->cron->create:$user->rights->cron->write; + $permtodelete = $user->rights->cron->delete; + $uploaddir = $conf->cron->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + if ($permtocreate) + { + $tmpcron = new Cronjob($db); + foreach($toselect as $id) + { + $result = $tmpcron->fetch($id); + if ($result) + { + $result = 0; + if ($massaction == 'disable') $result = $tmpcron->setStatut(Cronjob::STATUS_DISABLED); + elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED); + else dol_print_error($db, 'Bad value for massaction'); + if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors'); + } + else + { + $error++; + } + } + } } @@ -196,8 +246,8 @@ $sql.= " t.libname,"; $sql.= " t.test"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " WHERE 1 = 1"; -if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1'); -if ($status == 2) $sql.= " AND t.status = 2"; +if ($search_status >= 0 && $search_status < 2) $sql.= " AND t.status = ".(empty($search_status)?'0':'1'); +if ($search_status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { foreach($filter as $key => $value) { @@ -235,16 +285,17 @@ if (! $result) dol_print_error($db); $num = $db->num_rows($result); -$param='&status='.$status; +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param = ''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($search_status) $param.='&search_status='.$search_status; if ($search_label) $param.='&search_label='.$search_label; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour'); if ($action == 'delete') @@ -256,15 +307,28 @@ if ($action == 'execute') print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&securitykey='.$securitykey.$param, $langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); } +// List of mass actions available +$arrayofmassactions = array( +//'presend'=>$langs->trans("SendByMail"), +//'builddoc'=>$langs->trans("PDFMerge"), + 'enable'=>$langs->trans("Enable"), + 'disable'=>$langs->trans("Disable"), +); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); -print '
'."\n"; -print ''; + +print ''."\n"; if ($optioncss != '') print ''; print ''; +print ''; print ''; print ''; print ''; print ''; +print ''; +print ''; print ''; // Line with explanation and button new job @@ -277,7 +341,7 @@ else $buttontoshow.=''.$langs->trans("CronCreateJob").''; } -print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_setup', 0, $buttontoshow, '', $limit); +print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_setup', 0, $buttontoshow, '', $limit); print $langs->trans('CronInfo').'
'; @@ -288,8 +352,9 @@ print info_admin($text); print '
'; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=''; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''; @@ -311,7 +376,7 @@ print ''; print ''; print ''; print '\n"; @@ -467,6 +532,12 @@ if ($num > 0) } else { print "trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'),"playdisabled").""; } + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print '   '; + } print ''; print ''; diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 2b825450166..f471ffd7ce7 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -209,7 +209,7 @@ print load_fiche_titre($langs->trans("DonationsSetup"),$linkback,'title_setup'); $head = donation_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'payment'); +dol_fiche_head($head, 'general', $langs->trans("Donations"), -1, 'payment'); // Document templates diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index 42ba8270ba0..cc4078cfdbe 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -67,7 +67,7 @@ print load_fiche_titre($langs->trans("DonationsSetup"),$linkback,'title_setup'); $head = donation_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Donations"), 0, 'payment'); +dol_fiche_head($head, 'attributes', $langs->trans("Donations"), -1, 'payment'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 3d0e9e9623a..ced8111a93f 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -98,20 +98,21 @@ if ($action == 'update') { $object->fetch($id); - $object->firstname = GETPOST("firstname"); - $object->lastname = GETPOST("lastname"); - $object->societe = GETPOST("societe"); - $object->address = GETPOST("address"); - $object->amount = price2num(GETPOST("amount")); - $object->town = GETPOST("town"); - $object->zip = GETPOST("zipcode"); + $object->firstname = GETPOST("firstname",'alpha'); + $object->lastname = GETPOST("lastname",'alpha'); + $object->societe = GETPOST("societe",'alpha'); + $object->address = GETPOST("address",'alpha'); + $object->amount = price2num(GETPOST("amount",'alpha')); + $object->town = GETPOST("town",'alpha'); + $object->zip = GETPOST("zipcode",'alpha'); $object->country_id = GETPOST('country_id', 'int'); - $object->email = GETPOST("email"); + $object->email = GETPOST("email",'alpha'); $object->date = $donation_date; - $object->public = GETPOST("public"); - $object->fk_project = GETPOST("fk_project"); - $object->note_private= GETPOST("note_private"); - $object->note_public = GETPOST("note_public"); + $object->public = GETPOST("public",'alpha'); + $object->fk_project = GETPOST("fk_project",'alpha'); + $object->note_private= GETPOST("note_private",'none'); + $object->note_public = GETPOST("note_public",'none'); + $object->modepaymentid = GETPOST('modepayment','int'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -151,20 +152,21 @@ if ($action == 'add') if (! $error) { - $object->firstname = GETPOST("firstname"); - $object->lastname = GETPOST("lastname"); - $object->societe = GETPOST("societe"); - $object->address = GETPOST("address"); - $object->amount = price2num(GETPOST("amount")); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); + $object->firstname = GETPOST("firstname",'alpha'); + $object->lastname = GETPOST("lastname",'alpha'); + $object->societe = GETPOST("societe",'alpha'); + $object->address = GETPOST("address",'alpha'); + $object->amount = price2num(GETPOST("amount",'alpha')); + $object->zip = GETPOST("zipcode",'alpha'); + $object->town = GETPOST("town",'alpha'); $object->country_id = GETPOST('country_id', 'int'); - $object->email = GETPOST("email"); + $object->email = GETPOST("email",'alpha'); $object->date = $donation_date; - $object->note_private= GETPOST("note_private"); - $object->note_public = GETPOST("note_public"); - $object->public = GETPOST("public"); - $object->fk_project = GETPOST("fk_project"); + $object->note_private= GETPOST("note_private",'none'); + $object->note_public = GETPOST("note_public",'none'); + $object->public = GETPOST("public",'alpha'); + $object->fk_project = GETPOST("fk_project",'alpha'); + $object->modepaymentid = GETPOST('modepayment','int'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -348,6 +350,12 @@ if ($action == 'create') print "".''; + // Payment mode + print "\n"; + // Public note print ''; print ''; @@ -480,14 +488,14 @@ if (! empty($id) && $action == 'edit') print "".''; + // Payment mode print "\n"; + // Status print "".''; // Project @@ -764,7 +772,7 @@ if (! empty($id) && $action != 'edit') $filename = dol_sanitizeFileName($object->id); $filedir = $conf->don->dir_output . "/" . dol_sanitizeFileName($object->id); $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id; - $genallowed = ($object->statut == 2 && ($object->paid == 0 || $user->admin) && $user->rights->don->lire); + $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); $delallowed = $user->rights->don->creer; print $formfile->showdocuments('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 01ae466f132..56a685eef12 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -69,7 +69,7 @@ class Don extends CommonObject global $langs; $this->db = $db; - $this->modepaiementid = 0; + $this->modepaymentid = 0; $langs->load("donations"); $this->labelstatut[-1]=$langs->trans("Canceled"); @@ -338,7 +338,6 @@ class Don extends CommonObject $sql.= ", address"; $sql.= ", zip"; $sql.= ", town"; - // $sql.= ", country"; -- Deprecated $sql.= ", fk_country"; $sql.= ", public"; $sql.= ", fk_projet"; @@ -354,7 +353,7 @@ class Don extends CommonObject $sql.= " '".$this->db->idate($now)."'"; $sql.= ", ".$conf->entity; $sql.= ", ".price2num($this->amount); - $sql.= ", ".($this->modepaiementid?$this->modepaiementid:"null"); + $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null"); $sql.= ", '".$this->db->escape($this->firstname)."'"; $sql.= ", '".$this->db->escape($this->lastname)."'"; $sql.= ", '".$this->db->escape($this->societe)."'"; @@ -605,9 +604,10 @@ class Don extends CommonObject $sql = "SELECT d.rowid, d.datec, d.date_valid, d.tms as datem, d.datedon,"; $sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, "; - $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, "; + $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, d.email, d.phone, "; $sql.= " d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,"; $sql.= " p.ref as project_ref,"; + $sql.= " cp.libelle as payment_label, cp.code as payment_code,"; $sql.= " c.code as country_code, c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet"; @@ -657,7 +657,8 @@ class Don extends CommonObject $this->fk_project = $obj->fk_project; $this->public = $obj->public; $this->modepaymentid = $obj->fk_payment; - $this->modepayment = $obj->libelle; + $this->modepaymentcode = $obj->payment_code; + $this->modepayment = $obj->payment_label; $this->paid = $obj->paid; $this->amount = $obj->amount; $this->note_private = $obj->note_private; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 27b70e1b8cf..5ff1b133d20 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1272,7 +1272,7 @@ if ($action == 'create') print ''; } else diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 2120f6a5b2b..a2e39f7039c 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -29,7 +29,7 @@ create table llx_don fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise amount double(24,8) DEFAULT 0, - fk_payment integer, + fk_payment integer, -- Id of payment mode paid smallint default 0 NOT NULL, firstname varchar(50), lastname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index e6103ee8fb9..3aaca6f00b5 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -31,4 +31,4 @@ CREATE TABLE llx_expensereport_rules ( code_expense_rules_type varchar(50) NOT NULL, is_for_all tinyint DEFAULT '0', entity integer DEFAULT 1 -) ENGINE=InnoDB \ No newline at end of file +) ENGINE=InnoDB; \ No newline at end of file diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 44661c191d7..a891a2f590e 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -201,8 +201,10 @@ if ($action == "set") { $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer); } - else if ($conf->db->type == 'mssql') + else { + // Keyword ENGINE is MySQL-specific, so scrub it for + // other database types (mssql, pgsql) $buffer=preg_replace('/type=innodb/i','',$buffer); $buffer=preg_replace('/ENGINE=innodb/i','',$buffer); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 0fd9fe52b3e..1e6f9478313 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -707,6 +707,8 @@ WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only l CoreErrorTitle=System error CoreErrorMessage=Sorry, an error occurred. Contact your system administrator to check the logs or disable $dolibarr_main_prod=1 to get more information. CreditCard=Credit card +ValidatePayment=Validate payment +CreditOrDebitCard=Credit or debit card FieldsWithAreMandatory=Fields with %s are mandatory FieldsWithIsForPublic=Fields with %s are shown on public list of members. If you don't want this, check off the "public" box. AccordingToGeoIPDatabase=(according to GeoIP convertion) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index c4cb693716d..d90bfb35032 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -216,6 +216,7 @@ StartUpload=Start upload CancelUpload=Cancel upload FileIsTooBig=Files is too big PleaseBePatient=Please be patient... +NewPassword=New password ResetPassword=Reset password RequestToResetPasswordReceived=A request to change your Dolibarr password has been received NewKeyIs=This is your new keys to login diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index ae41f4df314..aec7404924b 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -29,4 +29,6 @@ ShortErrorMessage=Short Error Message ErrorCode=Error Code ErrorSeverityCode=Error Severity Code OnlinePaymentSystem=Online payment system -PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode) \ No newline at end of file +PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode) +PaypalImportPayment=Import Paypal payments +PostActionAfterPayment=Post actions after payments \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 5f71b230537..a064d032083 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -100,6 +100,7 @@ ActivityOnProjectThisMonth=Activity on project this month ActivityOnProjectThisYear=Activity on project this year ChildOfProjectTask=Child of project/task ChildOfTask=Child of task +TaskHasChild=Task has child NotOwnerOfProject=Not owner of this private project AffectedTo=Allocated to CantRemoveProject=This project can't be removed as it is referenced by some other objects (invoice, orders or other). See referers tab. diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index cb49994ea14..2b5823c28fb 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -37,4 +37,6 @@ STRIPE_TEST_SECRET_KEY=Secret test key STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key STRIPE_LIVE_SECRET_KEY=Secret live key STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key -StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode) \ No newline at end of file +StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode) +StripeImportPayment=Import Stripe payments +ExampleOfTestCreditCard=Example of credit card for test: %s (valid), %s (error CVC), %s (expired), %s (charge fails) \ No newline at end of file diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php index a8c280193ea..c2be67451cb 100755 --- a/htdocs/modulebuilder/template/scripts/myobject.php +++ b/htdocs/modulebuilder/template/scripts/myobject.php @@ -42,12 +42,17 @@ $error=0; @set_time_limit(0); // No timeout for this script define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". -// Include and load Dolibarr environment variables +// Load Dolibarr environment $res=0; -if (! $res && file_exists($path."master.inc.php")) $res=@include($path."master.inc.php"); -if (! $res && file_exists($path."../master.inc.php")) $res=@include($path."../master.inc.php"); -if (! $res && file_exists($path."../../master.inc.php")) $res=@include($path."../../master.inc.php"); -if (! $res && file_exists($path."../../../master.inc.php")) $res=@include($path."../../../master.inc.php"); +// Try master.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/master.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/master.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/master.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/master.inc.php"); +// Try master.inc.php using relative path +if (! $res && file_exists("../master.inc.php")) $res=@include("../master.inc.php"); +if (! $res && file_exists("../../master.inc.php")) $res=@include("../../master.inc.php"); +if (! $res && file_exists("../../../master.inc.php")) $res=@include("../../../master.inc.php"); if (! $res) die("Include of master fails"); // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). // $user is created but empty. diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 79a6a62ad2a..1db6c1906a3 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -55,6 +55,8 @@ if ($action == 'setvalue' && $user->admin) $result=dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT",GETPOST('PAYBOX_PBX_IDENTIFIANT','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; @@ -183,6 +185,15 @@ print '
'.$langs->trans("Example").': '.$mysoc->name; print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; +} + + print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; +} print '
   '; -print $form->selectarray('status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled"), '-2'=>$langs->trans("EnabledAndDisabled"), '2'=>$langs->trans("Archived")), $status, 1); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled"), '-2'=>$langs->trans("EnabledAndDisabled"), '2'=>$langs->trans("Archived")), $search_status, 1); print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; @@ -333,7 +398,7 @@ print_liste_field_titre("CronLastResult",$_SERVER["PHP_SELF"],"t.lastresult","", print_liste_field_titre("CronLastOutput",$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder); print_liste_field_titre("CronDtNextLaunch",$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"t.status,t.priority","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre(''); +print_liste_field_titre($selectedfields,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "
'.$langs->trans("EMail").'
".$langs->trans("PaymentMode")."\n"; + $selected = GETPOST('modepayment','int'); + $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1); + print "
' . $langs->trans('NotePublic') . '
'.$langs->trans("EMail").'
".$langs->trans("PaymentMode")."\n"; - if ($object->modepaymentid) $selected = $object->modepaymentid; else $selected = ''; - $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1); print "
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); + if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); print ''; print ''; } diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index a4b3b17a98a..d94baee2a43 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -59,14 +59,15 @@ class ExpeditionLineBatch extends CommonObject function fetchFromStock($id_stockdluo) { $sql = "SELECT"; - $sql.= " t.sellby,"; - $sql.= " t.eatby,"; - $sql.= " t.batch,"; - $sql.= " e.fk_entrepot"; + $sql.= " pb.batch,"; + $sql.= " pl.sellby,"; + $sql.= " pl.eatby,"; + $sql.= " ps.fk_entrepot"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t inner join "; - $sql.= MAIN_DB_PREFIX."product_stock as e on t.fk_product_stock=e.rowid "; - $sql.= " WHERE t.rowid = ".(int) $id_stockdluo; + $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql.= " JOIN ".MAIN_DB_PREFIX."product_stock as ps on pb.fk_product_stock=ps.rowid"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."product_lot as pl on pl.batch = pb.batch AND pl.fk_product = ps.fk_product"; + $sql.= " WHERE pb.rowid = ".(int) $id_stockdluo; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 877ba0f6e14..9ac776b08f8 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -347,9 +347,11 @@ if ($object->id > 0) // Nbre max d'elements des petites listes $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + print '
'; + // Lien recap $boxstat.='
'; - $boxstat.=''; + $boxstat.='
'; $boxstat.=''; $boxstat.='
'; if ($conf->supplier_proposal->enabled) diff --git a/htdocs/index.php b/htdocs/index.php index 3eb1aa2285a..29e716d31ad 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -339,14 +339,14 @@ if (empty($user->societe_id)) } } - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; $boxstat.='
'; @@ -583,12 +583,12 @@ if (! empty($valid_dashboardlines)) $boxwork .="\n"; } - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; $boxwork .='
'; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print '
'; print $langs->trans("CSSUrlForPaymentForm").''; print ''; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index 711f898901c..23bf26d375f 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -55,6 +55,8 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",GETPOST('PAYPAL_API_INTEGRAL_OR_PAYPALONLY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); @@ -210,6 +212,13 @@ print 'name; print '
'; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print '
'; print $langs->trans("CSSUrlForPaymentForm").''; diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index ecdd2f4fc3e..dc2e95c44da 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -192,7 +192,7 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f * @param string $returnURL Url to use if payment is OK * @param string $cancelURL Url to use if payment is KO * @param string $tag Full tag - * @return void + * @return string No return (a redirect is done) if OK, or Error message if KO */ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag) { @@ -272,11 +272,20 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - echo $langs->trans('SetExpressCheckoutAPICallFailed') . "
\n"; - echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; - echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; - echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; - echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + if ($ErrorCode == 10729) + { + $mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + } + else + { + $mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "
\n"; + $mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + $mesg.= $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + $mesg.= $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + $mesg.= $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + } + + return $mesg; } } @@ -300,6 +309,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re * phoneNum: the phoneNum entered on the merchant's site * email: the buyer email * desc: Product description + * See https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ * * @param double $paymentAmount Payment amount * @param string $currencyCodeType Currency @@ -307,8 +317,8 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re * @param string $returnURL Return Url * @param string $cancelURL Cancel Url * @param string $tag Full tag - * @param string $solutionType Type - * @param string $landingPage Landing page + * @param string $solutionType Type ('Mark' or 'Sole') + * @param string $landingPage Landing page ('Login' or 'Billing') * @param string $shipToName Ship to name * @param string $shipToStreet Ship to street * @param string $shipToCity Ship to city @@ -327,38 +337,86 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation //declaring of global variables - global $conf, $langs; + global $conf, $langs, $mysoc; global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; $nvpstr = ''; - $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr . "&VERSION=98.0"; $nvpstr = $nvpstr . "&RETURNURL=" . urlencode($returnURL); $nvpstr = $nvpstr . "&CANCELURL=" . urlencode($cancelURL); - $nvpstr = $nvpstr . "&CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE - $nvpstr = $nvpstr . "&ADDROVERRIDE=1"; - //$nvpstr = $nvpstr . "&ALLOWNOTE=0"; - $nvpstr = $nvpstr . "&SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME - $nvpstr = $nvpstr . "&SHIPTOSTREET=" . urlencode($shipToStreet); // - $nvpstr = $nvpstr . "&SHIPTOSTREET2=" . urlencode($shipToStreet2); - $nvpstr = $nvpstr . "&SHIPTOCITY=" . urlencode($shipToCity); - $nvpstr = $nvpstr . "&SHIPTOSTATE=" . urlencode($shipToState); - $nvpstr = $nvpstr . "&SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); - $nvpstr = $nvpstr . "&SHIPTOZIP=" . urlencode($shipToZip); - $nvpstr = $nvpstr . "&PHONENUM=" . urlencode($phoneNum); + if (! empty($conf->global->PAYPAL_ALLOW_NOTES)) + { + $nvpstr = $nvpstr . "&ALLOWNOTE=0"; + } + if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) + { + $nvpstr = $nvpstr . "&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted + } + else + { + $nvpstr = $nvpstr . "&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) + } $nvpstr = $nvpstr . "&SOLUTIONTYPE=" . urlencode($solutionType); $nvpstr = $nvpstr . "&LANDINGPAGE=" . urlencode($landingPage); - //$nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($tag); // Hotline phone number - $nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag); - if (! empty($email)) $nvpstr = $nvpstr . "&EMAIL=" . urlencode($email); - if (! empty($desc)) $nvpstr = $nvpstr . "&DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + if (! empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) + { + $nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number + } + $paypalprefix = 'PAYMENTREQUEST_0_'; + //$paypalprefix = ''; + if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale'; + + $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // Total for all elements + + $nvpstr = $nvpstr . "&".$paypalprefix."INVNUM=" . urlencode($tag); + $nvpstr = $nvpstr . "&".$paypalprefix."AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr . "&".$paypalprefix."ITEMAMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr . "&".$paypalprefix."PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr . "&".$paypalprefix."CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE + + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; + + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET=" . urlencode($shipToStreet); // + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET2=" . urlencode($shipToStreet2); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCITY=" . urlencode($shipToCity); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTATE=" . urlencode($shipToState); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip); + $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum); + if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + if (! empty($desc)) $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + + if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) + { + global $dolibarr_main_url_root; + + // 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 + + $urllogo=$urlwithroot."/viewimage.php?modulepart=mycompany&file=".$mysoc->logo; + $nvpstr = $nvpstr . "&LOGOIMG=" . urlencode($urllogo); + } + if (! empty($conf->global->PAYPAL_BRANDNAME)) + { + $nvpstr = $nvpstr . "&BRANDNAME=" . urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME + } + if (! empty($conf->global->PAYPAL_NOTETOBUYER)) + { + $nvpstr = $nvpstr . "&NOTETOBUYER=" . urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER + } $_SESSION["FinalPaymentAmt"] = $paymentAmount; $_SESSION["currencyCodeType"] = $currencyCodeType; - $_SESSION["PaymentType"] = $paymentType; - $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR ']; // Payer ip + $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' + $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 61bd5c3d47f..f732c44fc31 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -117,7 +117,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?resotre_lastsearch_values=1'); + header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index e6a2b59e700..caea260118f 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -332,7 +332,7 @@ $titletoadd=$langs->trans("Select"); $buttonrecord=$langs->trans("RecordMovement"); $titletoaddnoent=$langs->transnoentitiesnoconv("Select"); $buttonrecordnoent=$langs->transnoentitiesnoconv("RecordMovement"); -print $langs->trans("SelectProductInAndOutWareHouse",$titletoaddnoent,$buttonrecordnoent).'
'; +print ''.$langs->trans("SelectProductInAndOutWareHouse",$titletoaddnoent,$buttonrecordnoent).'
'; print '
'."\n"; $var=true; @@ -445,14 +445,14 @@ print ''; print ''; // Button to record mass movement -$codemove=(isset($_POST["codemove"])?GETPOST("codemove",'alpha'):dol_print_date(dol_now(),'%y%m%d%H%M%S')); +$codemove=(isset($_POST["codemove"])?GETPOST("codemove",'alpha'):dol_print_date(dol_now(),'%Y%m%d%H%M%S')); $labelmovement=GETPOST("label")?GETPOST('label'):$langs->trans("StockTransfer").' '.dol_print_date($now,'%Y-%m-%d %H:%M'); -print ''; +print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ed25f3ba813..bc78d285945 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -196,6 +196,7 @@ class Project extends CommonObject $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); + $sql.= ", " . ($this->bill_time ? 1 : 0); $sql.= ", ".$conf->entity; $sql.= ")"; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 85a6461fbfb..b70c09cb2bd 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -586,7 +586,7 @@ if ($id > 0 || ! empty($ref)) } else { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } } else diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 74ffcfd120a..350a73d3571 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -264,6 +264,7 @@ else if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$param * Actions */ +// Action dopayment is called after choosing the payment mode if ($action == 'dopayment') { if ($paymentmethod == 'paypal') @@ -310,6 +311,7 @@ if ($action == 'dopayment') dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + // All those fields may be empty when making a payment for a free amount for example dol_syslog("shipToName: $shipToName", LOG_DEBUG); dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); @@ -327,9 +329,10 @@ if ($action == 'dopayment') //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + $mesg = print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); - exit; + // If we are here, it means the Paypal redirect was not done, so we show error message + $action = ''; } } @@ -379,10 +382,12 @@ if ($action == 'dopayment') // Called when choosing Stripe mode, after the 'dopayment' if ($action == 'charge') { + $amountstripe = $amount; + // Correct the amount according to unit of currency // See https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($currency, $arrayzerounitcurrency)) $amount=$amount * 100; + if (! in_array($currency, $arrayzerounitcurrency)) $amountstripe=$amountstripe * 100; dol_syslog("POST keys : ".join(',', array_keys($_POST)), LOG_DEBUG, 0, '_stripe'); dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); @@ -411,7 +416,7 @@ if ($action == 'charge') dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, - 'amount' => price2num($amount, 'MU'), + 'amount' => price2num($amountstripe, 'MU'), 'currency' => $currency, 'description' => 'Stripe payment: '.$FULLTAG, 'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name), @@ -850,7 +855,7 @@ if ($source == 'invoice') print ''."\n"; // Amount - print '
'.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").''; - print ''; + print ''; print '
'.$langs->trans("Amount"); + print '
'.$langs->trans("PaymentAmount"); if (empty($amount) && empty($object->paye)) print ' ('.$langs->trans("ToComplete").')'; print ''; if (empty($object->paye)) @@ -1432,7 +1437,7 @@ if (preg_match('/^dopayment/',$action))
@@ -1442,7 +1447,7 @@ if (preg_match('/^dopayment/',$action))

- +
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d74305890df..7e5413e6509 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -44,13 +44,7 @@ if (! empty($conf->paypal->enabled)) require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("paybox"); -$langs->load("paypal"); +$langs->loadLangs(array("main","other","dict","bills","companies","paybox","paypal")); // Clean parameters if (! empty($conf->paypal->enabled)) @@ -130,6 +124,8 @@ $object = new stdClass(); // For triggers * View */ +$now = dol_now(); + dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_payment'); $tracepost = ""; @@ -183,7 +179,7 @@ if ($urllogo) if (! empty($conf->paypal->enabled)) { - if ($paymentmethod == 'paypal') + if ($paymentmethod == 'paypal') // We call this page only if payment is ok on payment system { if ($PAYPALTOKEN) { @@ -251,28 +247,187 @@ if (! empty($conf->paypal->enabled)) if (! empty($conf->paybox->enabled)) { - if ($paymentmethod == 'paybox') $ispaymentok = true; // We call this page only if payment is ok + if ($paymentmethod == 'paybox') $ispaymentok = true; // We call this page only if payment is ok on payment system } if (! empty($conf->stripe->enabled)) { - if ($paymentmethod == 'stripe') $ispaymentok = true; // We call this page only if payment is ok + if ($paymentmethod == 'stripe') $ispaymentok = true; // We call this page only if payment is ok on payment system } +// If data not provided from back url, search them into the session env +if (empty($ipaddress)) $ipaddress = $_SESSION['ipaddress']; +if (empty($TRANSACTIONID)) $TRANSACTIONID = $_SESSION['TRANSACTIONID']; +if (empty($FinalPaymentAmt)) $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; +if (empty($paymentType)) $paymentType = $_SESSION["paymentType"]; + +$fulltag = $FULLTAG; +$tmptag=dolExplodeIntoArray($fulltag,'.','='); + + +// Make complementary actions +$ispostactionok = 0; +$postactionmessages = array(); +if ($ispaymentok) +{ + if (in_array('MEM', array_keys($tmptag))) + { + // Record subscription + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($db); + $result = $member->fetch(0, $tmptag['MEM']); + if ($result) + { + if (empty($paymentType)) $paymentType = 'CB'; + $paymentTypeId = dol_getIdFromCode($db, $paymentType,'c_paiement','code','id',1); + + if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) + { + + + } + else + { + $postactionmessages[] = 'Failed to get a valid value for "amount paid" or "payment type" to record the payment of subscription for member '.$tmptag['MEM']; + $ispostactionok = -1; + } + } + else + { + $postactionmessages[] = 'Member for subscription payed '.$tmptag['MEM'].' was not found'; + $ispostactionok = -1; + } + } + elseif (in_array('INV', array_keys($tmptag))) + { + // Record payment + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $result = $invoice->fetch(0, $tmptag['INV']); + if ($result) + { + $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + + $paymentTypeId = 0; + if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; + if (empty($paymentTypeId)) + { + $paymentType = $_SESSION["paymentType"]; + if (empty($paymentType)) $paymentType = 'CB'; + $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); + } + + $currencyCodeType = $_SESSION['currencyCodeType']; + + if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) + { + // Creation of payment line + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paiement = new Paiement($db); + $paiement->datepaye = $now; + if ($currencyCodeType == $conf->currency) + { + $paiement->amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id + } + else + { + $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching + + $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; + $ispostactionok = -1; + $error++; // Not yet supported + } + $paiement->paiementid = $paymentTypeId; + $paiement->num_paiement = ''; + $paiement->note_public = 'Online payment using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; + + if (! $error) + { + $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents + if ($paiement_id < 0) + { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } + else + { + $postactionmessages[] = 'Payment created'; + $ispostactionok=1; + } + } + + if (! $error && ! empty($conf->banque->enabled)) + { + $bankaccountid = 0; + if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + + if ($bankaccountid > 0) + { + $label='(CustomerInvoicePayment)'; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result=$paiement->addPaymentToBank($user,'payment',$label, $bankaccountid, '', ''); + if ($result < 0) + { + $postactionmessages[] = $paiement->error.' '.joint("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } + else + { + $postactionmessages[] = 'Bank entry of payment created'; + $ispostactionok=1; + } + } + else + { + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Not way to record the payment.'; + $ispostactionok = -1; + $error++; + } + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['INV']; + $ispostactionok = -1; + } + } + else + { + $postactionmessages[] = 'Invoice payed '.$tmptag['INV'].' was not found'; + $ispostactionok = -1; + } + } + else + { + // Nothing done + } +} + if ($ispaymentok) { // Get on url call - $fulltag = $FULLTAG; $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - $TRANSACTIONID = $_SESSION['TRANSACTIONID']; // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -296,6 +451,10 @@ if ($ispaymentok) // Send an email if ($sendemail) { + $companylangs = new Translate('', $conf); + $companylangs->setDefaultLang($mysoc->default_lang); + $companylangs->loadLangs(array('main','members','bills','paypal','paybox')); + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot @@ -317,25 +476,56 @@ if ($ispaymentok) else $appli.=" ".DOL_VERSION; $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); + $topic='['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived"); $content=""; - if (! empty($tmptag['MEM'])) + if (in_array('MEM', array_keys($tmptag))) { - $langs->load("members"); $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
\n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; - $content.=$langs->trans("Link").': '.$url.''."
\n"; + $content.=''.$companylangs->trans("PaymentSubscription")."

\n"; + $content.=$companylangs->trans("MemberId").': '.$tmptag['MEM']."
\n"; + $content.=$companylangs->trans("Link").': '.$url.''."
\n"; + } + elseif (in_array('INV', array_keys($tmptag))) + { + $url=$urlwithroot."/compta/facture/card.php?ref=".$tmptag['INV']; + $content.=''.$companylangs->trans("Payment")."

\n"; + $content.=$companylangs->trans("Invoice").': '.$tmptag['INV']."
\n"; + //$content.=$companylangs->trans("ThirdPartyId").': '.$tmptag['CUS']."
\n"; + $content.=$companylangs->trans("Link").': '.$url.''."
\n"; } else { - $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; + $content.=$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; } + $content.=$companylangs->transnoentities("PostActionAfterPayment").' : '; + if ($ispostactionok > 0) + { + //$topic.=' ('.$companylangs->transnoentitiesnoconv("Status").' '.$companylangs->transnoentitiesnoconv("OK").')'; + $content.=''.$companylangs->transnoentitiesnoconv("OK").''; + } + elseif ($ispostactionok == 0) + { + $content.=$companylangs->transnoentitiesnoconv("None"); + } + else + { + $topic.=($ispostactionok ? '' : ' ('.$companylangs->trans("WarningPostActionErrorAfterPayment").')'); + $content.=''.$companylangs->transnoentitiesnoconv("Error").''; + } + $content.='
'."\n"; + foreach($postactionmessages as $postactionmessage) + { + $content.=' * '.$postactionmessage.'
'."\n"; + } + $content.='
'."\n"; + $content.="
\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + $content.=''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; + $content.=$companylangs->transnoentitiesnoconv("TransactionId").': '.$TRANSACTIONID."
\n"; + $content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="
\n"; + $content.="tag=".$fulltag."
\ntoken=".$onlinetoken."
\npaymentType=".$paymentType."
\ncurrencycodeType=".$currencyCodeType."
\npayerId=".$payerID."
\nipaddress=".$ipaddress."
\nFinalPaymentAmt=".$FinalPaymentAmt."
\n"; $ishtml=dol_textishtml($content); // May contain urls @@ -356,15 +546,12 @@ if ($ispaymentok) else { // Get on url call - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; + $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -389,12 +576,14 @@ else if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; if ($paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->STRIPE_PAYONLINE_SENDEMAIL; - $tmptag=dolExplodeIntoArray($fulltag,'.','='); - // Send an email if ($sendemail) { - $sendto=$sendemail; + $companylangs = new Translate('', $conf); + $companylangs->setDefaultLang($mysoc->default_lang); + $companylangs->loadLangs(array('main','members','bills','paypal','paybox')); + + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -415,14 +604,17 @@ else else $appli.=" ".DOL_VERSION; $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("ValidationOfPaymentFailed"); + $topic='['.$appli.'] '.$companylangs->transnoentitiesnoconv("ValidationOfPaymentFailed"); $content=""; - $content.=$langs->transnoentitiesnoconv("PaymentSystemConfirmPaymentPageWasCalledButFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + $content.=''.$companylangs->transnoentitiesnoconv("PaymentSystemConfirmPaymentPageWasCalledButFailed")."\n"; + + $content.="
\n"; + $content.=''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; + $content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="
\n"; + $content.="tag=".$fulltag."
\ntoken=".$onlinetoken."
\npaymentType=".$paymentType."
\ncurrencycodeType=".$currencyCodeType."
\npayerId=".$payerID."
\nipaddress=".$ipaddress."
\nFinalPaymentAmt=".$FinalPaymentAmt."
\n"; + $ishtml=dol_textishtml($content); // May contain urls @@ -448,6 +640,10 @@ print "\n\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs,0,$suffix); +// Clean session variables to avoid duplicate actions if post is resent +unset($_SESSION["FinalPaymentAmt"]); +unset($_SESSION["TRANSACTIONID"]); + llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index b1ecfa43803..24abc52526c 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -250,7 +250,7 @@ if (GETPOST('action','aZ09') == 'dopayment') //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + $mesg = print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); exit; } diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 36cd64b4f01..ff1b03187c1 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -1168,7 +1168,7 @@ if (preg_match('/^dopayment/',$action))
- +
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8e77bbcf147..67b1bf605aa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1170,7 +1170,7 @@ class Societe extends CommonObject $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($ref_alias)."'"; if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; @@ -2900,10 +2900,10 @@ class Societe extends CommonObject //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) + return 1; + else + return -1; //algorithm checking type code CIF $sum = $num[2] + $num[4] + $num[6]; @@ -2913,36 +2913,56 @@ class Societe extends CommonObject //Chek special NIF if (preg_match('/^[KLM]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) + return 1; + else + return -1; //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else - return -2; + if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) + return 2; + else + return -2; //Check NIE T if (preg_match('/^[T]{1}/', $string)) - if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else - return -3; + if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) + return 3; + else + return -3; //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else - return -3; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + return 3; + else + return -3; //Can not be verified return -4; } + //Verify NIF if country is PT + //Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad + if ($idprof == 1 && $soc->country_code == 'PT') + { + $string=trim($this->idprof1); + $string=preg_replace('/(\s)/','',$string); + + for ($i = 0; $i < 9; $i ++) { + $num[$i] = substr($string, $i, 1); + } + + //Check NIF + if (preg_match('/(^[0-9]{9}$)/', $string)) { + return 1; + } + else { + return -1; + } + } + return $ok; } @@ -2964,20 +2984,33 @@ class Societe extends CommonObject $hookmanager->initHooks(array('idprofurl')); $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; + if (empty($reshook)) { + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + return ''; + } // TODO Move links to validate professional ID into a dictionary table "country" + "link" - if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ - //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid - if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; - if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + if ($idprof == 1 && $thirdparty->country_code == 'FR') { + $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ + } + if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { + $url='https://beta.companieshouse.gov.uk/company/'.$thirdparty->idprof1; + } + if ($idprof == 1 && $thirdparty->country_code == 'ES') { + $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; + } + if ($idprof == 1 && $thirdparty->country_code == 'IN') { + $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + } + if ($idprof == 1 && $thirdparty->country_code == 'PT') { + $url='http://www.nif.pt/'.$thirdparty->idprof1; + } - if ($url) return ''.$langs->trans("Check").''; + if ($url) { + return ''.$langs->trans("Check").''; + } } - else - { + else { return $hookmanager->resPrint; } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index c658e19fa20..8f7a8ae9d86 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -56,7 +56,9 @@ if ($action == 'setvalue' && $user->admin) $result=dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY",GETPOST('STRIPE_LIVE_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM",GETPOST('ONLINE_PAYMENT_MESSAGE_FORM','alpha'),'chaine',0,'',$conf->entity); @@ -195,6 +197,14 @@ print 'name; print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print ''; +} + print ''; print $langs->trans("CSSUrlForPaymentForm").''; print ''; @@ -253,6 +263,8 @@ $token=''; include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php'; +print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242', '4000000000000101', '4000000000000069', '4000000000000341')); + if (! empty($conf->use_javascript_ajax)) { print "\n".'