From 081be37787e745c96f5806237a511766522d0bc7 Mon Sep 17 00:00:00 2001 From: moreauf Date: Mon, 14 Nov 2016 19:25:50 +0100 Subject: [PATCH 01/46] NEW: Add project and Hook to Loan BUG: Correct discard_closed parametters management in project --- htdocs/core/class/html.formprojet.class.php | 2 +- .../install/mysql/migration/4.0.0-5.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_loan.sql | 3 +- htdocs/loan/card.php | 320 ++++++++++-------- htdocs/loan/class/loan.class.php | 9 +- htdocs/projet/ajax/projects.php | 3 +- 6 files changed, 198 insertions(+), 141 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 1112d34d13f..ddc26d0bb91 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -79,7 +79,7 @@ class FormProjets $project->fetch($selected); $selected_input_value=$project->ref; } - $urloption='socid='.$socid.'&htmlname='.$htmlname; + $urloption='socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed; $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( // 'update' => array( // 'projectid' => 'id' diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index fb862457b45..76aa7d85928 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -221,4 +221,4 @@ drop table tmp_links_double; ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); - +ALTER TABLE llx_loan ADD COLUMN fk_project integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index 6fd3c0d2099..64d1de5dc29 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -47,5 +47,6 @@ create table llx_loan fk_user_author integer DEFAULT NULL, fk_user_modif integer DEFAULT NULL, - active tinyint DEFAULT 1 NOT NULL + active tinyint DEFAULT 1 NOT NULL, + fk_project integer DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 0894447d485..b24f9c75253 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -28,6 +28,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} $langs->load("compta"); $langs->load("bills"); @@ -45,134 +50,143 @@ $result = restrictedArea($user, 'loan', $id, '',''); $object = new Loan($db); +$hookmanager->initHooks(array('loancard','globalcard')); + /* * Actions */ -// Classify paid -if ($action == 'confirm_paid' && $confirm == 'yes') -{ - $object->fetch($id); - $result = $object->set_paid($user); - if ($result > 0) - { - setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); - } - else - { - setEventMessages($loan->error, null, 'errors'); - } -} +$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 loan -if ($action == 'confirm_delete' && $confirm == 'yes') +if (empty($reshook)) { - $object->fetch($id); - $result=$object->delete($user); - if ($result > 0) + // Classify paid + if ($action == 'confirm_paid' && $confirm == 'yes') { - setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); - header("Location: index.php"); - exit; + $object->fetch($id); + $result = $object->set_paid($user); + if ($result > 0) + { + setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); + } + else + { + setEventMessages($loan->error, null, 'errors'); + } } - else - { - setEventMessages($loan->error, null, 'errors'); - } -} -// Add loan -if ($action == 'add' && $user->rights->loan->write) -{ - if (! $cancel) + // Delete loan + if ($action == 'confirm_delete' && $confirm == 'yes') { - $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); - $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - - if (! $datestart) + $object->fetch($id); + $result=$object->delete($user); + if ($result > 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); - $action = 'create'; - } - elseif (! $dateend) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); - $action = 'create'; - } - elseif (! $_POST["capital"]) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); - $action = 'create'; + setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); + header("Location: index.php"); + exit; } else { - $object->label = $_POST["label"]; - $object->fk_bank = $_POST["accountid"]; - $object->capital = $_POST["capital"]; - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = $_POST["nbterm"]; - $object->rate = $_POST["rate"]; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + setEventMessages($loan->error, null, 'errors'); + } + } - $accountancy_account_capital = GETPOST('accountancy_account_capital'); - $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); - $accountancy_account_interest = GETPOST('accountancy_account_interest'); + // Add loan + if ($action == 'add' && $user->rights->loan->write) + { + if (! $cancel) + { + $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); + $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } - - $id=$object->create($user); - if ($id <= 0) + if (! $datestart) { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); + $action = 'create'; + } + elseif (! $dateend) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); + $action = 'create'; + } + elseif (! $_POST["capital"]) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); + $action = 'create'; + } + else + { + $object->label = $_POST["label"]; + $object->fk_bank = $_POST["accountid"]; + $object->capital = $_POST["capital"]; + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->nbterm = $_POST["nbterm"]; + $object->rate = $_POST["rate"]; + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + $object->fk_project = GETPOST('fk_project'); + + $accountancy_account_capital = GETPOST('accountancy_account_capital'); + $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); + $accountancy_account_interest = GETPOST('accountancy_account_interest'); + + if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } + if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } + if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + + $id=$object->create($user); + if ($id <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } } } - } - else - { - header("Location: index.php"); - exit(); - } -} - -// Update record -else if ($action == 'update' && $user->rights->loan->write) -{ - if (! $cancel) - { - $result = $object->fetch($id); - - if ($object->fetch($id)) + else { - $object->label = GETPOST("label"); - $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); - $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); - $object->nbterm = GETPOST("nbterm"); - $object->rate = GETPOST("rate"); + header("Location: index.php"); + exit(); } + } - $result = $object->update($user); + // Update record + else if ($action == 'update' && $user->rights->loan->write) + { + if (! $cancel) + { + $result = $object->fetch($id); - if ($result > 0) - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } + if ($object->fetch($id)) + { + $object->label = GETPOST("label"); + $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $object->nbterm = GETPOST("nbterm"); + $object->rate = GETPOST("rate"); + $object->fk_project = GETPOST("fk_project"); + } + + $result = $object->update($user); + + if ($result > 0) + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + } } - /* * View */ @@ -240,6 +254,20 @@ if ($action == 'create') // Rate print ''.$langs->trans("Rate").' %'; + // Project + if (! empty($conf->projet->enabled)) + { + $formproject=new FormProjets($db); + + // Projet associe + $langs->load("projects"); + + print ''.$langs->trans("Project").''; + + $numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1); + + print ''; + } // Note Private print ''; print ''.$langs->trans('NotePrivate').''; @@ -283,8 +311,8 @@ if ($action == 'create') print ''; print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1); print ''; - } - else // For external software + } + else // For external software { // Accountancy_account_capital print ''.$langs->trans("LoanAccountancyCapitalCode").''; @@ -300,11 +328,11 @@ if ($action == 'create') print ''.$langs->trans("LoanAccountancyInterestCode").''; print ''; print ''; - + print ''; } print ''; - + dol_fiche_end(); print '
     '; @@ -438,6 +466,23 @@ if ($id > 0) } print ''; + // projet + if (! empty($conf->projet->enabled)){ + print ''; + print $langs->trans("Project"); + print ''; + if ($action == 'edit') { + $formproject=new FormProjets($db); + $numproject=$formproject->select_projects(-1,$object->fk_project,'fk_project',16,0,1,1); + + } else { + $project=new Project($db); + $project->fetch($object->fk_project); + print $project->getNomUrl(1,'',1);; + } + print ''; + } + // Status print ''.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).''; @@ -445,7 +490,7 @@ if ($id > 0) dol_fiche_end(); - + if ($action == 'edit') { print '
'; @@ -455,7 +500,7 @@ if ($id > 0) print '
'; print '

'; } - + print ''; print ''; } @@ -473,11 +473,11 @@ if ($id > 0) print ''; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 8ed6e682ce6..ac0062d3ed9 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -50,7 +50,7 @@ class Loan extends CommonObject var $fk_bank; var $fk_user_creat; var $fk_user_modif; - var $fk_project; + var $fk_projet; /** @@ -73,7 +73,7 @@ class Loan extends CommonObject function fetch($id) { $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; - $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest,l.fk_project"; + $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest,l.fk_projet"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -100,7 +100,7 @@ class Loan extends CommonObject $this->account_capital = $obj->accountancy_account_capital; $this->account_insurance = $obj->accountancy_account_insurance; $this->account_interest = $obj->accountancy_account_interest; - $this->fk_project = $obj->fk_project; + $this->fk_projet = $obj->fk_projet; $this->db->free($resql); return 1; @@ -128,7 +128,7 @@ class Loan extends CommonObject function create($user) { global $conf; - + $error=0; $now=dol_now(); @@ -143,7 +143,7 @@ class Loan extends CommonObject if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); - if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); + if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet); // Check parameters if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) @@ -161,7 +161,7 @@ class Loan extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public"; $sql.= " ,accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity"; - $sql.= " ,datec,fk_project,fk_user_author)"; + $sql.= " ,datec,fk_projet,fk_user_author)"; $sql.= " VALUES ('".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->fk_bank)."',"; $sql.= " '".price2num($newcapital)."',"; @@ -176,7 +176,7 @@ class Loan extends CommonObject $sql.= " '".$this->db->escape($this->account_interest)."',"; $sql.= " ".$conf->entity.","; $sql.= " '".$this->db->idate($now)."',"; - $sql.= " '".$this->fk_project."',"; + $sql.= " ".(empty($this->fk_projet)?'NULL':$this->fk_projet).","; $sql.= " ".$user->id; $sql.= ")"; @@ -284,7 +284,7 @@ class Loan extends CommonObject $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; - $sql.= " fk_project='".$this->db->escape($this->fk_project)."',"; + $sql.= " fk_projet=".(empty($this->fk_projet)?'NULL':$this->fk_projet).","; $sql.= " fk_user_modif = ".$user->id; $sql.= " WHERE rowid=".$this->id; @@ -348,7 +348,7 @@ class Loan extends CommonObject global $langs; $langs->load('customers'); $langs->load('bills'); - + if ($mode == 0) { if ($statut == 0) return $langs->trans("Unpaid"); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 958f0b242a2..9abcc1d0771 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -47,6 +47,7 @@ if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compt if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $langs->load("projects"); $langs->load("companies"); @@ -58,6 +59,7 @@ if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); if (! empty($conf->deplacement->enabled)) $langs->load("trips"); if (! empty($conf->expensereport->enabled)) $langs->load("trips"); if (! empty($conf->don->enabled)) $langs->load("donations"); +if (! empty($conf->loan->enabled)) $langs->load("loan"); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -370,6 +372,19 @@ $listofreferent=array( 'buttonnew'=>'AddDonation', 'testnew'=>$user->rights->don->creer, 'test'=>$conf->don->enabled && $user->rights->don->lire), +'loan'=>array( + 'name'=>"Loan", + 'title'=>"ListLoanAssociatedProject", + 'class'=>'Loan', + 'margin'=>'add', + 'table'=>'Loan', + 'datefieldname'=>'datestart', + 'disableamount'=>0, + 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'loan', + 'buttonnew'=>'AddLoan', + 'testnew'=>$user->rights->loan->creer, + 'test'=>$conf->loan->enabled && $user->rights->loan->lire), 'agenda'=>array( 'name'=>"Agenda", 'title'=>"ListActionsAssociatedProject", @@ -397,9 +412,9 @@ $parameters=array('listofreferent'=>$listofreferent); $resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action); if(!empty($hookmanager->resArray)) { - + $listofreferent = array_merge($listofreferent, $hookmanager->resArray); - + } if ($action=="addelement") @@ -490,7 +505,7 @@ foreach ($listofreferent as $key => $value) $element = new $classname($db); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); - + if (count($elementarray)>0 && is_array($elementarray)) { $total_ht = 0; @@ -506,7 +521,7 @@ foreach ($listofreferent as $key => $value) $element->fetch($idofelement); if ($idofelementuser) $elementuser->fetch($idofelementuser); - // Special cases + // Special cases if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename == 'don') $total_ht_by_line=$element->amount; elseif ($tablename == 'projet_task') @@ -529,7 +544,7 @@ foreach ($listofreferent as $key => $value) { if (! empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal=false; // Replacement invoice, do not include into total } - + if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line; if ($tablename == 'don') $total_ttc_by_line=$element->amount; @@ -795,7 +810,7 @@ foreach ($listofreferent as $key => $value) print ' - '.dol_trunc($element->label, 48); } else print $element->getNomUrl(1); - + $element_doc = $element->element; $filename=dol_sanitizeFileName($element->ref); $filedir=$conf->{$element_doc}->dir_output . '/' . dol_sanitizeFileName($element->ref); @@ -811,7 +826,7 @@ foreach ($listofreferent as $key => $value) } print '
'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'
'; - + // Show supplier ref if (! empty($element->ref_supplier)) print ' - '.$element->ref_supplier; // Show customer ref @@ -826,7 +841,7 @@ foreach ($listofreferent as $key => $value) elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status)) { if ($tablename=='don') $date = $element->datedon; - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') { $date=($element->date_commande?$element->date_commande:$element->date_valid); } From ff734bb5d9379f5ca42b105783df5e0589a11a09 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 16 Nov 2016 09:40:29 +0100 Subject: [PATCH 03/46] Fix travis --- htdocs/core/lib/functions.lib.php | 144 +++++++++++++++--------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 677b619bd02..e535dd9f928 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -191,7 +191,7 @@ function getBrowserInfo($user_agent) elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } - + if ($tablet) { $layout = 'tablet'; } elseif ($phone) { @@ -256,14 +256,14 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) { $tmp=dol_getdate(dol_now(), true); $out = $tmp['mon']; - } + } elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $out = $tmp['year']; } } - + switch ($check) { case 'int': @@ -387,15 +387,15 @@ function dol_buildpath($path, $type=0) if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value if ($type == 3) $res = DOL_URL_ROOT.'/'.$path; - + foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) { - if ($key == 'main') + if ($key == 'main') { if ($type == 3) { 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 @@ -422,12 +422,12 @@ function dol_buildpath($path, $type=0) if ($type == 3) { 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 - + $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax } break; @@ -693,13 +693,13 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' throw new Exception('Incorrect log level'); } if ($level > $conf->global->SYSLOG_LEVEL) return; - + // If adding log inside HTML page is required if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility { $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; } - + //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) @@ -708,7 +708,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' print $message."\n"; print "Log end -->\n"; } - + $data = array( 'message' => $message, 'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false), @@ -716,7 +716,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' 'user' => ((is_object($user) && $user->id) ? $user->login : false), 'ip' => false ); - + if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; @@ -903,7 +903,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { $out = $hookmanager->resPrint; } - + return $out; } @@ -944,8 +944,8 @@ function dol_get_fiche_end($notab=0) * @param int $nodbprefix Do not include DB prefix to forge table name * @param string $morehtmlleft More html code to show before ref * @param string $morehtmlstatus More html code to show under navigation arrows - * @param string $morehtmlright More html code to show before navigation arrows * @param int $onlybanner Put this to 1, if the card will contains only a banner + * @param string $morehtmlright More html code to show before navigation arrows * @return void */ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='') @@ -962,7 +962,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'member') $modulepart='memberphoto'; if ($object->element == 'user') $modulepart='userphoto'; if ($object->element == 'product') $modulepart='product'; - + if ($object->element == 'product') { $width=80; $cssclass='photoref'; @@ -970,7 +970,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); if ($conf->browser->phone) $maxvisiblephotos=1; if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; - else + else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { $nophoto=''; @@ -980,14 +980,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $nophoto='/public/theme/common/nophoto.png'; $morehtmlleft.='
No photo
'; } - + } } - else + else { - if ($showimage) + if ($showimage) { - if ($modulepart != 'unknown') + if ($modulepart != 'unknown') { $phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos); if ($phototoshow) @@ -1000,7 +1000,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r elseif ($conf->browser->layout != 'phone') // Show no photo link { $morehtmlleft.='
'; - if ($object->element == 'action') + if ($object->element == 'action') { $cssclass='photorefcenter'; $nophoto=img_picto('', 'title_agenda', '', false, 1); @@ -1019,7 +1019,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($showbarcode) $morehtmlleft.='
'.$form->showbarcode($object).'
'; if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); - } + } elseif ($object->element == 'product') { //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; @@ -1039,21 +1039,21 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r elseif ($object->element == 'facture' || $object->element == 'invoice' || $object->element == 'invoice_supplier') { $tmptxt=$object->getLibStatut(6, $object->totalpaye); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } - elseif ($object->element == 'facturerec') + elseif ($object->element == 'facturerec') { $morehtmlstatus.=''; } else { // Generic case $tmptxt=$object->getLibStatut(6); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); $morehtmlstatus.=$tmptxt; } if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; // For thirdparty if (! empty($object->label)) $morehtmlref.='
'.$object->label.'
'; // For product - if ($object->element != 'product') + if ($object->element != 'product') { $morehtmlref.='
'; $morehtmlref.=$object->getBannerAddress('refaddress',$object); @@ -1065,7 +1065,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $morehtmlref.=$langs->trans("TechnicalID").': '.$object->id; $morehtmlref.='
'; } - + print '
'; print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright); print '
'; @@ -1240,9 +1240,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0; $formatwithoutreduce = preg_replace('/reduceformat/','',$format); if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day - + // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. - // TODO Add format daysmallyear and dayhoursmallyear + // TODO Add format daysmallyear and dayhoursmallyear if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); @@ -1744,7 +1744,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep $newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4); } } - + if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) { if (! empty($conf->browser->phone) || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone @@ -1874,7 +1874,7 @@ function dol_user_country() * @param int $mode thirdparty|contact|member|other * @param int $id Id of object * @param int $noprint No output. Result is the function return - * @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br. + * @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br. * @return string|void Nothing if noprint is 0, formatted address if noprint is 1 * @see dol_format_address */ @@ -1895,7 +1895,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0, $charfornl { if (empty($charfornl)) $out.=nl2br($address); else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); - + $showgmap=$showomap=0; // TODO Add a hook here @@ -2023,7 +2023,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', print '
'.$langs->trans("NotEnoughDataYet").'
'; return; } - + if (empty($conf->use_javascript_ajax)) return; $jsgraphlib='flot'; $datacolor=array(); @@ -2192,7 +2192,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo global $conf; if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - + if (empty($stringencoding)) $stringencoding='UTF-8'; // reduce for small screen if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); @@ -3144,7 +3144,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', * @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder) * @param string $sortfield Field to sort on ('' by default) * @param string $sortorder Order to sort ('' by default) - * @param string $center Strin gin the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction() + * @param string $center Strin gin the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction() * @param int $num Number of records found by select with limit+1 * @param int $totalnboflines Total number of records/lines for all pages (if known). Use a negative value to not show number. * @param string $picto Icon to use before title (should be a 32x32 transparent png file) @@ -3158,11 +3158,11 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) { global $conf,$langs; - + $savlimit = $limit; $savtotalnboflines = $totalnboflines; $totalnboflines=abs($totalnboflines); - + if ($picto == 'setup') $picto='title_setup.png'; if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; if ($limit < 0) $limit = $conf->liste_limit; @@ -3175,7 +3175,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $nextpage = 0; } //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage; - + print "\n"; print "\n"; print '
'; @@ -537,33 +582,38 @@ if ($id > 0) */ if ($action != 'edit') { - print '
'; + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { + print '
'; - // Edit - if ($user->rights->loan->write) - { - print ''.$langs->trans("Modify").''; + // Edit + if ($user->rights->loan->write) + { + print ''.$langs->trans("Modify").''; + } + + // Emit payment + if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) + { + print ''.$langs->trans("DoPayment").''; + } + + // Classify 'paid' + if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) + { + print ''.$langs->trans("ClassifyPaid").''; + } + + // Delete + if ($user->rights->loan->delete) + { + print ''.$langs->trans("Delete").''; + } + + print "
"; } - - // Emit payment - if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) - { - print ''.$langs->trans("DoPayment").''; - } - - // Classify 'paid' - if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) - { - print ''.$langs->trans("ClassifyPaid").''; - } - - // Delete - if ($user->rights->loan->delete) - { - print ''.$langs->trans("Delete").''; - } - - print "
"; } } else diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 5c57764bf97..8ed6e682ce6 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -50,6 +50,7 @@ class Loan extends CommonObject var $fk_bank; var $fk_user_creat; var $fk_user_modif; + var $fk_project; /** @@ -72,7 +73,7 @@ class Loan extends CommonObject function fetch($id) { $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; - $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest"; + $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest,l.fk_project"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -99,6 +100,7 @@ class Loan extends CommonObject $this->account_capital = $obj->accountancy_account_capital; $this->account_insurance = $obj->accountancy_account_insurance; $this->account_interest = $obj->accountancy_account_interest; + $this->fk_project = $obj->fk_project; $this->db->free($resql); return 1; @@ -141,6 +143,7 @@ class Loan extends CommonObject if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); // Check parameters if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) @@ -158,7 +161,7 @@ class Loan extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public"; $sql.= " ,accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity"; - $sql.= " ,datec, fk_user_author)"; + $sql.= " ,datec,fk_project,fk_user_author)"; $sql.= " VALUES ('".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->fk_bank)."',"; $sql.= " '".price2num($newcapital)."',"; @@ -173,6 +176,7 @@ class Loan extends CommonObject $sql.= " '".$this->db->escape($this->account_interest)."',"; $sql.= " ".$conf->entity.","; $sql.= " '".$this->db->idate($now)."',"; + $sql.= " '".$this->fk_project."',"; $sql.= " ".$user->id; $sql.= ")"; @@ -280,6 +284,7 @@ class Loan extends CommonObject $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; + $sql.= " fk_project='".$this->db->escape($this->fk_project)."',"; $sql.= " fk_user_modif = ".$user->id; $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 55a4597dc08..3140352bf60 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -37,6 +37,7 @@ $htmlname=GETPOST('htmlname','alpha'); $socid=GETPOST('socid','int'); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); +$discard_closed =GETPOST('discardclosed','int'); /* @@ -63,7 +64,7 @@ if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; $searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); $form = new FormProjets($db); -$arrayresult=$form->select_projects_list($socid, '', $htmlname, 0, 0, 1, 0, 0, 0, 1, $searchkey); +$arrayresult=$form->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); $db->close(); From a251f0df51eec143a42e23de6133a4c66e60b0d3 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 16 Nov 2016 09:38:13 +0100 Subject: [PATCH 02/46] Various fix on Loan and project link --- .../install/mysql/migration/4.0.0-5.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_loan.sql | 2 +- htdocs/loan/card.php | 10 +++--- htdocs/loan/class/loan.class.php | 18 +++++------ htdocs/projet/element.php | 31 ++++++++++++++----- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 42f7e8fd76c..5f5581a6d48 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -223,4 +223,4 @@ ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; -ALTER TABLE llx_loan ADD COLUMN fk_project integer DEFAULT NULL; +ALTER TABLE llx_loan ADD COLUMN fk_projet integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index 64d1de5dc29..c6d8147fe47 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -48,5 +48,5 @@ create table llx_loan fk_user_author integer DEFAULT NULL, fk_user_modif integer DEFAULT NULL, active tinyint DEFAULT 1 NOT NULL, - fk_project integer DEFAULT NULL + fk_projet integer DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index b24f9c75253..8d8c938f641 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -127,7 +127,7 @@ if (empty($reshook)) $object->rate = $_POST["rate"]; $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); - $object->fk_project = GETPOST('fk_project'); + $object->fk_projet = GETPOST('fk_projet'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -165,7 +165,7 @@ if (empty($reshook)) $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); $object->nbterm = GETPOST("nbterm"); $object->rate = GETPOST("rate"); - $object->fk_project = GETPOST("fk_project"); + $object->fk_projet = GETPOST("fk_projet"); } $result = $object->update($user); @@ -264,7 +264,7 @@ if ($action == 'create') print '
'.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1); + $numproject=$formproject->select_projects(-1,GETPOST("fk_projet"),'fk_projet',16,0,1,1); print '
'; if ($action == 'edit') { $formproject=new FormProjets($db); - $numproject=$formproject->select_projects(-1,$object->fk_project,'fk_project',16,0,1,1); + $numproject=$formproject->select_projects(-1,$object->fk_projet,'fk_projet',16,0,1,1); } else { $project=new Project($db); - $project->fetch($object->fk_project); + $project->fetch($object->fk_projet); print $project->getNomUrl(1,'',1);; } print '
'; @@ -3276,7 +3276,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported //$pagesizechoices.=',2:2'; if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES; - + print ''; } @@ -473,11 +473,11 @@ if ($id > 0) print ''; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index ac0062d3ed9..bf6d67930ae 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -50,7 +50,7 @@ class Loan extends CommonObject var $fk_bank; var $fk_user_creat; var $fk_user_modif; - var $fk_projet; + var $fk_project; /** @@ -73,7 +73,7 @@ class Loan extends CommonObject function fetch($id) { $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; - $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest,l.fk_projet"; + $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest,l.fk_project"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -100,7 +100,7 @@ class Loan extends CommonObject $this->account_capital = $obj->accountancy_account_capital; $this->account_insurance = $obj->accountancy_account_insurance; $this->account_interest = $obj->accountancy_account_interest; - $this->fk_projet = $obj->fk_projet; + $this->fk_project = $obj->fk_project; $this->db->free($resql); return 1; @@ -143,7 +143,7 @@ class Loan extends CommonObject if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); - if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet); + if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); // Check parameters if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) @@ -161,7 +161,7 @@ class Loan extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public"; $sql.= " ,accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity"; - $sql.= " ,datec,fk_projet,fk_user_author)"; + $sql.= " ,datec,fk_project,fk_user_author)"; $sql.= " VALUES ('".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->fk_bank)."',"; $sql.= " '".price2num($newcapital)."',"; @@ -176,7 +176,7 @@ class Loan extends CommonObject $sql.= " '".$this->db->escape($this->account_interest)."',"; $sql.= " ".$conf->entity.","; $sql.= " '".$this->db->idate($now)."',"; - $sql.= " ".(empty($this->fk_projet)?'NULL':$this->fk_projet).","; + $sql.= " ".(empty($this->fk_project)?'NULL':$this->fk_project).","; $sql.= " ".$user->id; $sql.= ")"; @@ -284,7 +284,7 @@ class Loan extends CommonObject $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; - $sql.= " fk_projet=".(empty($this->fk_projet)?'NULL':$this->fk_projet).","; + $sql.= " fk_project=".(empty($this->fk_project)?'NULL':$this->fk_project).","; $sql.= " fk_user_modif = ".$user->id; $sql.= " WHERE rowid=".$this->id; From 056b76a831930b5a1931f993879adbbdd96acf92 Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 10:34:22 +0000 Subject: [PATCH 05/46] Better Separator for Products/Services in Top Menu Easier to read when both modules are enabled --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7b5e5d98d9d..67bc5674443 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -112,7 +112,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $chaine.=$langs->trans("Products"); } if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) { - $chaine.="/"; + $chaine.=" | "; } if (! empty($conf->service->enabled)) { $chaine.=$langs->trans("Services"); From 86d195fa811daeb2c8082689598ed91e2e27dcaf Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 10:37:15 +0000 Subject: [PATCH 06/46] Add Unique Top Menu Translation Add unique top menu translation for products/services so it can be better translated separately from other words/links using the same text. --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 67bc5674443..441bbd2da31 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -109,13 +109,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $chaine=""; if (! empty($conf->product->enabled)) { - $chaine.=$langs->trans("Products"); + $chaine.=$langs->trans("TMenuProducts"); } if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) { $chaine.=" | "; } if (! empty($conf->service->enabled)) { - $chaine.=$langs->trans("Services"); + $chaine.=$langs->trans("TMenuServices"); } if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); From f96fd895e3c8bb1a4f8b768f871ee46c6fcebecd Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 10:40:45 +0000 Subject: [PATCH 07/46] Add Products/Services Menu Translation String Add the translation string into language file --- htdocs/langs/en_US/products.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 27b64a4399d..7ce98277a73 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -5,6 +5,8 @@ ProductLabelTranslated=Translated product label ProductDescriptionTranslated=Translated product description ProductNoteTranslated=Translated product note ProductServiceCard=Products/Services card +TMenuProducts=PRODUCTS +TMenuServices=SERVICES Products=Products Services=Services Product=Product From 636fbb476c4eee92424bb3f9e55057bef30b13a0 Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 10:49:12 +0000 Subject: [PATCH 08/46] Add Unique Top Menu Translation Add unique top menu translation for Tools so it can be better translated separately from other words/links using the same text. --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 441bbd2da31..fe3b36860a9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -259,7 +259,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $idsel='tools'; if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); if (empty($noout)) print_end_menu_entry($showmode); $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", ''); } From 5c46095fa37b6ee559ebc6123f2e83449273a62f Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 10:52:30 +0000 Subject: [PATCH 09/46] Add Translation String for Tools Add translation string so it can be used independently for the top menu --- htdocs/langs/en_US/other.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 1ea1f9da1db..69e0a808e62 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -2,6 +2,7 @@ SecurityCode=Security code NumberingShort=N° Tools=Tools +TMenuTools=TOOLS ToolsDesc=All miscellaneous tools not included in other menu entries are collected here.

All the tools can be reached in the left menu. Birthday=Birthday BirthdayDate=Birthday date From 9f2879515947574e8bb33517c41711a54c5793bc Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 11:29:35 +0000 Subject: [PATCH 10/46] Add Unique Top Menu Translation Add unique top menu translation for products/services so it can be better translated separately from other words/links using the same text. ** Requires re-enabling module --- htdocs/core/modules/modAgenda.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 47e6fb43d5c..80cc63ac610 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -189,7 +189,7 @@ class modAgenda extends DolibarrModules // $r++; $this->menu[$r]=array('fk_menu'=>0, 'type'=>'top', - 'titre'=>'Agenda', + 'titre'=>'TMenuAgenda', 'mainmenu'=>'agenda', 'url'=>'/comm/action/index.php', 'langs'=>'agenda', From 6ebafe1a871405420882a8459b705d9cc41c25a7 Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 11:32:28 +0000 Subject: [PATCH 11/46] Add Translation String for Agenda Add translation string so it can be used independently for the top menu --- htdocs/langs/en_US/agenda.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index b626d991615..48b1862d706 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -2,6 +2,7 @@ IdAgenda=ID event Actions=Events Agenda=Agenda +TMenuAgenda=AGENDA Agendas=Agendas LocalAgenda=Internal calendar ActionsOwnedBy=Event owned by From d5fe7b8b9c3d25ffab2c2815d17f4cb6df78fa16 Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 12:21:47 +0000 Subject: [PATCH 12/46] Add Search Tip for User Add a simple tip on the search strings which could be used by the end user when they are searching from the main search box. Tested strings are '*' and *|* This would be very useful to the end user and new users --- htdocs/langs/en_US/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a3851b89339..4da744b2a75 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -775,7 +775,7 @@ SetRef=Set ref Select2ResultFoundUseArrows=Some results found. Use arrows to select. Select2NotFound=No result found Select2Enter=Enter -Select2MoreCharacter=or more character +Select2MoreCharacter=or more characters

SEARCH PARAMETERS:
[without spaces]

| OR
* SEARCH ALL
Select2MoreCharacters=or more characters Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... From 5a8b844c49468c7cb2ece00ac0fcc654e6992c4a Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 22:41:08 +0000 Subject: [PATCH 13/46] Update other.lang --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 69e0a808e62..253560454ec 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -2,7 +2,7 @@ SecurityCode=Security code NumberingShort=N° Tools=Tools -TMenuTools=TOOLS +TMenuTools=Tools ToolsDesc=All miscellaneous tools not included in other menu entries are collected here.

All the tools can be reached in the left menu. Birthday=Birthday BirthdayDate=Birthday date From 9bb60e8d2c2cb3c31356138973fa6a3ebf8afdee Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 22:41:35 +0000 Subject: [PATCH 14/46] Update agenda.lang --- htdocs/langs/en_US/agenda.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 48b1862d706..f378ec7afbc 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -2,7 +2,7 @@ IdAgenda=ID event Actions=Events Agenda=Agenda -TMenuAgenda=AGENDA +TMenuAgenda=Agenda Agendas=Agendas LocalAgenda=Internal calendar ActionsOwnedBy=Event owned by From 66693c52682e7ec8e93deaa48a0a7b17fca4c334 Mon Sep 17 00:00:00 2001 From: IJ Date: Sat, 19 Nov 2016 22:42:03 +0000 Subject: [PATCH 15/46] Update products.lang --- htdocs/langs/en_US/products.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 7ce98277a73..a228a9ef4df 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -5,8 +5,8 @@ ProductLabelTranslated=Translated product label ProductDescriptionTranslated=Translated product description ProductNoteTranslated=Translated product note ProductServiceCard=Products/Services card -TMenuProducts=PRODUCTS -TMenuServices=SERVICES +TMenuProducts=Products +TMenuServices=Services Products=Products Services=Services Product=Product From b631db1d6062032470403447daed0afb65d301f0 Mon Sep 17 00:00:00 2001 From: IJ Date: Tue, 22 Nov 2016 02:29:25 +0000 Subject: [PATCH 16/46] New: Add Hidden Options Quick Reference Link Add the dolibarr wiki link for quick reference from the page Setup>Other Setup --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ca53bc971a9..c4dee6a5da1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -982,7 +982,7 @@ TriggerAlwaysActive=Triggers in this file are always active, whatever are the ac TriggerActiveAsModuleActive=Triggers in this file are active as module %s is enabled. GeneratedPasswordDesc=Define here which rule you want to use to generate new password if you ask to have auto generated password DictionaryDesc=Insert all reference data. You can add your values to the default. -ConstDesc=This page allows you to edit all other parameters not available in previous pages. These are mostly reserved parameters for developers or advanced troubleshooting. +ConstDesc=This page allows you to edit all other parameters not available in previous pages. These are mostly reserved parameters for developers or advanced troubleshooting. For a list of options check here. MiscellaneousDesc=All other security related parameters are defined here. LimitsSetup=Limits/Precision setup LimitsDesc=You can define limits, precisions and optimisations used by Dolibarr here From eb62c1eb0dd189189daf55e101da91f8eca6dc62 Mon Sep 17 00:00:00 2001 From: tarrsalah Date: Wed, 4 Jan 2017 16:35:04 +0100 Subject: [PATCH 17/46] fix undefined method getProjectsAuthorizedForUser. When a user don't have the permission `$user->rights->projet->all->lire`, viewing some tasks related entities (like `tasks/contact.php?id=1&withproject=1`) cause `Call to undefined method Task::getProjectsAuthorizedForUser()` fatal error. The problem is caused by calling getProjectsAuthorizedForUser on $object insted of $projectstatic. --- htdocs/projet/tasks/contact.php | 2 +- htdocs/projet/tasks/document.php | 2 +- htdocs/projet/tasks/note.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/projet/tasks/time.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index dcb9f7426a8..096f44cc2f2 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -208,7 +208,7 @@ if ($id > 0 || ! empty($ref)) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 7c62fb651f1..e51c0fb28cc 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -151,7 +151,7 @@ if ($object->id > 0) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index f443facaabf..9ee9c160ad0 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -130,7 +130,7 @@ if ($object->id > 0) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index cbee3683f73..2e5c17acc59 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -242,7 +242,7 @@ if ($id > 0 || ! empty($ref)) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 5a9a6704566..d0b9475bfc1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -318,7 +318,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } From 983efdd6ee98b430c471141f118d5979f2b047da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jan 2017 18:13:36 +0100 Subject: [PATCH 18/46] FIX repair tool was ko to restore extrafields with type select. --- htdocs/install/repair.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 090e980a9e5..94750073d71 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -252,10 +252,34 @@ if ($ok) if (! in_array($code,array_keys($arrayoffieldsfound))) { print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; - $type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null'; + $type=$extrafields->attribute_type[$code]; $length=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null'; + + if ($type=='boolean') { + $typedb='int'; + $lengthdb='1'; + } elseif($type=='price') { + $typedb='double'; + $lengthdb='24,8'; + } elseif($type=='phone') { + $typedb='varchar'; + $lengthdb='20'; + }elseif($type=='mail') { + $typedb='varchar'; + $lengthdb='128'; + } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ + $typedb='text'; + $lengthdb=''; + } elseif ($type=='link') { + $typedb='int'; + $lengthdb='11'; + } else { + $typedb=$type; + $lengthdb=$length; + } + $field_desc=array( - 'type'=>$type, - 'value'=>$value, + 'type'=>$typedb, + 'value'=>$lengthdb, 'attribute'=>$attribute, 'default'=>$default, 'extra'=>$extra, From 4002ec9fd5a8e109983883a8d074798ff69bea5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jan 2017 15:51:08 +0100 Subject: [PATCH 19/46] Fix css install and login --- htdocs/install/default.css | 4 ++-- htdocs/theme/eldy/style.css.php | 30 +++++++++++++++++++++--------- htdocs/theme/md/style.css.php | 10 +++++++++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index dfde26cdedb..257f2d99af8 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -343,8 +343,8 @@ ul { .button { - background: #eee; - /*border: 1px solid #C0C0C0;*/ + background: #fcfcfc; + border: 1px solid #d0d0d0; padding: 0.3em 0.7em; margin: 0 0.5em; -moz-border-radius:0 5px 0 5px; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0e278019df6..97ec72bb55d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -337,9 +337,9 @@ input[type=checkbox] { background-color: transparent; border: none; box-shadow: input[type=radio] { background-color: transparent; border: none; box-shadow: none; } input[type=image] { background-color: transparent; border: none; box-shadow: none; } input:-webkit-autofill { - background-color: #FBFFEA !important; + background-color: #FDFFF0 !important; background-image:none !important; - -webkit-box-shadow: 0 0 0 50px #FBFFEA inset; + -webkit-box-shadow: 0 0 0 50px #FDFFF0 inset; } ::-webkit-input-placeholder { color:#ccc; } :-moz-placeholder { color:#bbb; } /* firefox 18- */ @@ -1375,6 +1375,7 @@ foreach($mainmenuusedarray as $val) .bodylogin { background: #f0f0f0; + /* background: linear-gradient(to left top, rgb(255,255,255), rgb(240,240,240)) fixed; */ } .login_vertical_align { padding: 10px; @@ -1406,12 +1407,23 @@ form#login { -moz-box-shadow: 0 2px 23px 2px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(60,60,60,0.15); -webkit-box-shadow: 0 2px 23px 2px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(60,60,60,0.15); box-shadow: 0 2px 23px 2px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(60,60,60,0.15); + /*-moz-box-shadow: 3px 2px 20px #CCC; -webkit-box-shadow: 3px 2px 20px #CCC; box-shadow: 3px 2px 20px #CCC;*/ border-radius: 5px; - border:solid 1px rgba(80,80,80,.4); + /*border-top:solid 1px rgba(180,180,180,.4); + border-left:solid 1px rgba(180,180,180,.4); + border-right:solid 1px rgba(180,180,180,.4); + border-bottom:solid 1px rgba(180,180,180,.4);*/ +} +.login_table input#username, .login_table input#password, .login_table input#securitycode{ + border: none; + border-bottom: solid 1px rgba(180,180,180,.4); + padding: 5px; + margin-left: 18px; + margin-top: 5px; } .login_main_message { text-align: center; @@ -1448,8 +1460,8 @@ table.login_table_securitycode tr td { border: 1px solid #DDDDDD; } #img_logo, .img_logo { - max-width: 200px; - max-height: 100px; + max-width: 150px; + max-height: 80px; } div.login_block { @@ -1523,18 +1535,18 @@ img.loginphoto { height: 16px; } .span-icon-user { - /* background-image: url(); */ + background-image: url(); background-repeat: no-repeat; } .span-icon-password { - /* background-image: url(); */ + background-image: url(); background-repeat: no-repeat; } - +/* .span-icon-user input, .span-icon-password input { /* margin-left: 18px; */ margin-left: 0px; -} +}*/ /* ============================================================================== */ /* Menu gauche */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f45b0355880..c8ecb538624 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1453,6 +1453,13 @@ form#login { border-top:solid 1px f8f8f8; } +.login_table input#username, .login_table input#password, .login_table input#securitycode{ + border: none; + border-bottom: solid 1px rgba(180,180,180,.4); + padding: 5px; + margin-left: 18px; + margin-top: 5px; +} .login_main_message { text-align: center; max-width: 560px; @@ -1567,7 +1574,8 @@ img.loginphoto { } .span-icon-user { - background: url() no-repeat scroll 7px 7px; + background-image: url(); + background-repeat: no-repeat; } .span-icon-password { background-image: url(); From 9cfc8d4095a17aaadb6937e482a5b69bdc4593df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jan 2017 19:58:38 +0100 Subject: [PATCH 20/46] Fix several problems into OAuth2 module. --- htdocs/admin/oauthlogintokens.php | 225 ++++++++++++++---- htdocs/core/lib/oauth.lib.php | 8 +- .../modules/oauth/github_oauthcallback.php | 171 +++++++++++++ .../modules/oauth/google_oauthcallback.php | 12 +- .../modules/printing/printgcp.modules.php | 21 +- .../OAuth/Common/Storage/DoliStorage.php | 19 +- htdocs/langs/en_US/oauth.lang | 9 +- htdocs/langs/en_US/printing.lang | 2 +- htdocs/printing/admin/printing.php | 17 +- 9 files changed, 412 insertions(+), 72 deletions(-) create mode 100644 htdocs/core/modules/oauth/github_oauthcallback.php diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index b41ae78d4c7..93306e8d13c 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -104,6 +104,11 @@ if ($action == 'setvalue' && $user->admin) * View */ +// 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 + $form = new Form($db); llxHeader('',$langs->trans("PrintingSetup")); @@ -127,70 +132,191 @@ if ($mode == 'setup' && $user->admin) if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; if (! $supported) continue; // show only supported + + $OAUTH_SERVICENAME='Unknown'; + if ($key[0] == 'OAUTH_GITHUB_NAME') + { + $OAUTH_SERVICENAME='GitHub'; + $urltorenew=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms='https://github.com/settings/applications/'; + } + if ($key[0] == 'OAUTH_GOOGLE_NAME') + { + $OAUTH_SERVICENAME='Google'; + $urltorenew=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms='https://security.google.com/settings/security/permissions'; + } + + // Show value of token + $tokenobj=null; + // Token + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; + // Dolibarr storage + $storage = new DoliStorage($db, $conf); + try + { + $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); + } + catch(Exception $e) + { + // Return an error if token not found + } + + // Set other properties + $refreshtoken=false; + $expiredat=''; + + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if (is_object($tokenobj)) { + $expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30)); + } + + // Token expired so we refresh it + if (is_object($tokenobj) && $expire) { + try { + // il faut sauvegarder le refresh token car le provider ne le donne qu'une seule fois + $refreshtoken = $tokenobj->getRefreshToken(); + $tokenobj = $apiService->refreshAccessToken($tokenobj); + $tokenobj->setRefreshToken($refreshtoken); + $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj); + } catch (Exception $e) { + setEventMessages($e->getMessage(), null, 'errors'); + } + } + if ($key[1] != '' && $key[2] != '') { + if (is_object($tokenobj)) { + $refreshtoken = $tokenobj->getRefreshToken(); + + $endoflife = $tokenobj->getEndOfLife(); + if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) + { + $expiredat = $langs->trans("Never"); + } + elseif ($endoflife == $tokenobj::EOL_UNKNOWN) + { + $expiredat = $langs->trans("Unknown"); + } + else + { + $expiredat=dol_print_date($endoflife, "dayhour"); + } + } + } + + $submit_enabled=0; + print '
'; print ''; print ''; print '
'.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1,GETPOST("fk_projet"),'fk_projet',16,0,1,1); + $numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1); print '
'; if ($action == 'edit') { $formproject=new FormProjets($db); - $numproject=$formproject->select_projects(-1,$object->fk_projet,'fk_projet',16,0,1,1); + $numproject=$formproject->select_projects(-1,$object->fk_project,'fk_project',16,0,1,1); } else { $project=new Project($db); - $project->fetch($object->fk_projet); + $project->fetch($object->fk_project); print $project->getNomUrl(1,'',1);; } print '
'."\n"; - $var=true; + + $var=false; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; - $submit_enabled=0; - + print ''; - print ''.$langs->trans($key['varname']).''; - print ''; + print ''; + //var_dump($key); + print $langs->trans("OAuthIDSecret").''; + print ''; print ''; print ''."\n"; - // Show value of token - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("IsTokenGenerated"); + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''."\n"; + //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ? + print ''.$langs->trans('DeleteAccess').'

'; } + // Request remote token + print ''.$langs->trans('RequestAccess').'

'; + // Check remote access + if ($urltocheckperms) + { + print $langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': '.$urltocheckperms.''; + } + print ''; + print ''; + + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("Token").''; + print ''; + print ''."\n"; + + if (is_object($tokenobj)) + { + // Token refresh + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_REFRESH").''; + print ''; + print ''; + // Token expired + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_EXPIRED").''; + print ''; + print ''; + + // Token expired at + $var = ! $var; + print ''; + print ''; + //var_dump($key); + print $langs->trans("TOKEN_EXPIRE_AT").''; + print ''; + print ''; + } + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' '.$langs->trans($key[0]).'
'.$langs->trans($key['info']).''; + print $langs->trans("SeePreviousTab"); + print ''; - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') - { - // Delete remote tokens - if (! empty($key['delete'])) print ''.$langs->trans('DeleteAccess').'

'; - // Request remote token - print ''.$langs->trans('RequestAccess').'

'; - // Check remote access - print $langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME_GOOGLE).': https://security.google.com/settings/security/permissions'; - } print '
'; + if (is_object($tokenobj)) print $langs->trans("HasAccessToken"); + else print $langs->trans("NoAccessToken"); + print ''; + // Links to delete/checks token + if (is_object($tokenobj)) { - // Token - print '
'.$langs->trans("Token").''; - // Dolibarr storage - $storage = new DoliStorage($db, $conf); - try - { - $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE); - } - catch(Exception $e) - { - // Return an error if token not found - } - if (is_object($tokenobj)) - { - //var_dump($tokenobj); - print $tokenobj->getAccessToken().'
'; - //print 'Refresh: '.$tokenobj->getRefreshToken().'
'; - //print 'EndOfLife: '.$tokenobj->getEndOfLife().'
'; - //var_dump($tokenobj->getExtraParams()); - /*print '
Extra:
';*/ - } - print '
'; - print '
'; + if (is_object($tokenobj)) + { + //var_dump($tokenobj); + print $tokenobj->getAccessToken().'
'; + //print 'Refresh: '.$tokenobj->getRefreshToken().'
'; + //print 'EndOfLife: '.$tokenobj->getEndOfLife().'
'; + //var_dump($tokenobj->getExtraParams()); + /*print '
Extra:
';*/ + } + print '
'; + print yn($refreshtoken); + print '
'; + print yn($expire); + print '
'; + print $expiredat; + print '
'; if (! empty($driver)) @@ -199,7 +325,8 @@ if ($mode == 'setup' && $user->admin) print '
'; } } - + + print ''; } diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 6f47ef6e62b..0149b581fa2 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -26,9 +26,13 @@ // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) $supportedoauth2array=array( 'OAUTH_GOOGLE_NAME'=>'google', - 'OAUTH_GITHUB_NAME'=>'github' ); +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + $supportedoauth2array['OAUTH_GITHUB_NAME']='github'; +} +$supportedoauth2array['OAUTH_GITHUB_NAME']='github'; // API access parameters OAUTH $list = array ( array( @@ -264,7 +268,7 @@ function oauthadmin_prepare_head() $h++; $head[$h][0] = dol_buildpath('/admin/oauthlogintokens.php', 1); - $head[$h][1] = $langs->trans("ManualTokenGeneration"); + $head[$h][1] = $langs->trans("TokenManager"); $head[$h][2] = 'tokengeneration'; $h++; diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php new file mode 100644 index 00000000000..83c3da66a47 --- /dev/null +++ b/htdocs/core/modules/oauth/github_oauthcallback.php @@ -0,0 +1,171 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/modules/oauth/github_oauthcallback.php + * \ingroup oauth + * \brief Page to get oauth callback + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; +use OAuth\Common\Storage\DoliStorage; +use OAuth\Common\Consumer\Credentials; +use OAuth\OAuth2\Service\GitHub; + +// 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 + + + +$action = GETPOST('action', 'alpha'); +$backtourl = GETPOST('backtourl', 'alpha'); + + +/** + * Create a new instance of the URI class with the current URI, stripping the query string + */ +$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); +//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); +//$currentUri->setQuery(''); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/github_oauthcallback.php'); + + +/** + * Load the credential for the service + */ + +/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */ +$serviceFactory = new \OAuth\ServiceFactory(); +$httpClient = new \OAuth\Common\Http\Client\CurlClient(); +// TODO Set options for proxy and timeout +// $params=array('CURLXXX'=>value, ...) +//$httpClient->setCurlParameters($params); +$serviceFactory->setHttpClient($httpClient); + +// Dolibarr storage +$storage = new DoliStorage($db, $conf); + +// Setup the credentials for the requests +$credentials = new Credentials( + $conf->global->OAUTH_GITHUB_ID, + $conf->global->OAUTH_GITHUB_SECRET, + $currentUri->getAbsoluteUri() +); + +$requestedpermissionsarray=array(); +if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back +if ($action != 'delete' && empty($requestedpermissionsarray)) +{ + print 'Error, parameter state is not defined'; + exit; +} +//var_dump($requestedpermissionsarray);exit; + +// Instantiate the Api service using the credentials, http client and storage mechanism for the token +/** @var $apiService Service */ +$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray); + +// access type needed to have oauth provider refreshing token +//$apiService->setAccessType('offline'); + +$langs->load("oauth"); + + +/* + * Actions + */ + + +if ($action == 'delete') +{ + $storage->clearToken('GitHub'); + + setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + + header('Location: ' . $backtourl); + exit(); +} + +if (! empty($_GET['code'])) // We are coming from oauth provider page +{ + //llxHeader('',$langs->trans("OAuthSetup")); + + //$linkback=''.$langs->trans("BackToModuleList").''; + //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); + + //dol_fiche_head(); + // retrieve the CSRF state parameter + $state = isset($_GET['state']) ? $_GET['state'] : null; + //print ''; + + // This was a callback request from service, get the token + try { + //var_dump($_GET['code']); + //var_dump($state); + //var_dump($apiService); // OAuth\OAuth2\Service\GitHub + + //$token = $apiService->requestAccessToken($_GET['code'], $state); + $token = $apiService->requestAccessToken($_GET['code']); + // Github is a service that does not need state yo be stored. + // Into constructor of GitHub, the call + // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri) + // has not the ending parameter to true like the Google class constructor. + + setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token + } catch (Exception $e) { + print $e->getMessage(); + } + + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + header('Location: ' . $backtourl); + exit(); +} +else // If entry on page with no parameter, we arrive here +{ + $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + + // This may create record into oauth_state before the header redirect. + // Creation of record with state in this tables depend on the Provider used (see its constructor). + if (GETPOST('state')) + { + $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); + } + else + { + $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated + } + + // we go on oauth provider authorization page + header('Location: ' . $url); + exit(); +} + + +/* + * View + */ + +// No view at all, just actions + +$db->close(); + diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 3068a29098c..c69493ed9a5 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/oauth/getoauthcallback.php + * \file htdocs/core/modules/oauth/google_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -83,7 +83,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray)) /** @var $apiService Service */ $apiService = $serviceFactory->createService('Google', $credentials, $storage, $requestedpermissionsarray); -// access type needed for google refresh token +// access type needed to have oauth provider refreshing token $apiService->setAccessType('offline'); $langs->load("oauth"); @@ -104,7 +104,7 @@ if ($action == 'delete') exit(); } -if (! empty($_GET['code'])) // We are coming from Google oauth page +if (! empty($_GET['code'])) // We are coming from oauth provider page { //llxHeader('',$langs->trans("OAuthSetup")); @@ -121,6 +121,7 @@ if (! empty($_GET['code'])) // We are coming from Google oauth page //var_dump($_GET['code']); //var_dump($state); //var_dump($apiService); // OAuth\OAuth2\Service\Google + $token = $apiService->requestAccessToken($_GET['code'], $state); setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token @@ -138,6 +139,8 @@ else // If entry on page with no parameter, we arrive here { $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + // This may create record into oauth_state before the header redirect. + // Creation of record with state in this tables depend on the Provider used (see its constructor). if (GETPOST('state')) { $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); @@ -146,7 +149,8 @@ else // If entry on page with no parameter, we arrive here { $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated } - // we go on google authorization page + + // we go on oauth provider authorization page header('Location: ' . $url); exit(); } diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 3d086466c87..baa5106ae93 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -66,6 +66,7 @@ class printing_printgcp extends PrintingDriver $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 + $this->db = $db; if (!$conf->oauth->enabled) { @@ -117,10 +118,28 @@ class printing_printgcp extends PrintingDriver $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { + $expiredat=''; + $refreshtoken = $token->getRefreshToken(); + + $endoflife=$token->getEndOfLife(); + + if ($endoflife == $token::EOL_NEVER_EXPIRES) + { + $expiredat = $langs->trans("Never"); + } + elseif ($endoflife == $token::EOL_UNKNOWN) + { + $expiredat = $langs->trans("Unknown"); + } + else + { + $expiredat=dol_print_date($endoflife, "dayhour"); + } + $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); - $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info'); + $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info'); } /* if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) { diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php index 7e82bb63cb2..463afe194db 100644 --- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php +++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php @@ -97,7 +97,7 @@ class DoliStorage implements TokenStorageInterface $this->tokens = array(); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " WHERE service='".$service."' AND entity=1"; + $sql.= " WHERE service='".$this->db->escape($service)."' AND entity=1"; $resql = $this->db->query($sql); if (! $resql) { @@ -113,7 +113,7 @@ class DoliStorage implements TokenStorageInterface } else { // save $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, token, entity)"; - $sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)"; + $sql.= " VALUES ('".$this->db->escape($service)."', '".$this->db->escape($serializedToken)."', 1)"; $resql = $this->db->query($sql); } //print $sql; @@ -130,7 +130,7 @@ class DoliStorage implements TokenStorageInterface // get from db dol_syslog("hasAccessToken service=".$service); $sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " WHERE service='".$service."'"; + $sql.= " WHERE service='".$this->db->escape($service)."'"; $resql = $this->db->query($sql); if (! $resql) { @@ -159,7 +159,7 @@ class DoliStorage implements TokenStorageInterface // unset($tokens[$service]); $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " WHERE service='".$service."'"; + $sql.= " WHERE service='".$this->db->escape($service)."'"; $resql = $this->db->query($sql); //} @@ -189,7 +189,7 @@ class DoliStorage implements TokenStorageInterface } - throw new AuthorizationStateNotFoundException('State not found in conf, are you sure you stored it?'); + throw new AuthorizationStateNotFoundException('State not found in db, are you sure you stored it?'); } /** @@ -207,7 +207,7 @@ class DoliStorage implements TokenStorageInterface $this->states[$service] = $state; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state"; - $sql.= " WHERE service='".$service."' AND entity=1"; + $sql.= " WHERE service='".$this->db->escape($service)."' AND entity=1"; $resql = $this->db->query($sql); if (! $resql) { @@ -223,7 +223,7 @@ class DoliStorage implements TokenStorageInterface } else { // save $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_state (service, state, entity)"; - $sql.= " VALUES ('".$service."', '".$state."', 1)"; + $sql.= " VALUES ('".$this->db->escape($service)."', '".$this->db->escape($state)."', 1)"; $resql = $this->db->query($sql); } @@ -236,9 +236,10 @@ class DoliStorage implements TokenStorageInterface */ public function hasAuthorizationState($service) { - // get from db + // get state from db + dol_syslog("get state from db"); $sql = "SELECT state FROM ".MAIN_DB_PREFIX."oauth_state"; - $sql.= " WHERE service='".$service."'"; + $sql.= " WHERE service='".$this->db->escape($service)."'"; $resql = $this->db->query($sql); $result = $this->db->fetch_array($resql); $states[$service] = $result[state]; diff --git a/htdocs/langs/en_US/oauth.lang b/htdocs/langs/en_US/oauth.lang index f4df2dc3dda..cafca379f6f 100644 --- a/htdocs/langs/en_US/oauth.lang +++ b/htdocs/langs/en_US/oauth.lang @@ -2,15 +2,20 @@ ConfigOAuth=Oauth Configuration OAuthServices=OAuth services ManualTokenGeneration=Manual token generation +TokenManager=Token manager +IsTokenGenerated=Is token generated ? NoAccessToken=No access token saved into local database HasAccessToken=A token was generated and saved into local database -NewTokenStored=Token received ans saved -ToCheckDeleteTokenOnProvider=To check/delete authorization saved by %s OAuth provider +NewTokenStored=Token received and saved +ToCheckDeleteTokenOnProvider=Click here to check/delete authorization saved by %s OAuth provider TokenDeleted=Token deleted RequestAccess=Click here to request/renew access and receive a new token to save DeleteAccess=Click here to delete token UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider: ListOfSupportedOauthProviders=Enter here credential provided by your OAuth2 provider. Only supported OAuth2 providers are visible here. This setup may be used by other modules that need OAuth2 authentication. +OAuthSetupForLogin=Page to generate an OAuth token +SeePreviousTab=See previous tab +OAuthIDSecret=OAuth ID and Secret TOKEN_REFRESH=Token Refresh Present TOKEN_EXPIRED=Token expired TOKEN_EXPIRE_AT=Token expire at diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index d6cf49bd525..a357409289a 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -46,6 +46,6 @@ IPP_Media=Printer media IPP_Supported=Type of media DirectPrintingJobsDesc=This page lists printing jobs found for available printers. GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret. -GoogleAuthConfigured=Google OAuth credentials found into setup of module OAuth. +GoogleAuthConfigured=Google OAuth credentials were found into setup of module OAuth. PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print. PrintTestDescprintgcp=List of Printers for Google Cloud Print. diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 8e9a9d20b9a..8d9609459ed 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -161,9 +161,19 @@ if ($mode == 'setup' && $user->admin) break; case "info": // Google Api setup or Google OAuth Token print ''; - print ''.$langs->trans($key['varname']).''; + print ''; + if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') + { + print $langs->trans("IsTokenGenerated"); + } + else + { + print $langs->trans($key['varname']); + } + print ''; print ''; print ''; print ''; - print ''; - print ''; print ''."\n"; } } From 005a40c105fc1fea495be2d0f205d6caa047f2bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 14:17:35 +0100 Subject: [PATCH 21/46] Fix css on login page. Pb with autocomplete-autofill. --- htdocs/core/tpl/login.tpl.php | 4 ++-- htdocs/theme/eldy/style.css.php | 16 ++++++++++++---- htdocs/theme/md/style.css.php | 14 +++++++++++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 5e79b71ee34..ae1118b4ce7 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -102,9 +102,9 @@ $(document).ready(function () { background: #FFF; border-right: 1px solid rgba(0,0,0,0.2); + box-shadow: 3px 0 6px -2px #eee; bottom: 0; color: #333; display: block; @@ -1460,6 +1462,12 @@ form#login { margin-left: 18px; margin-top: 5px; } +.login_table input#username:focus, .login_table input#password:focus, .login_table input#securitycode:focus { + outline: none !important; + /* box-shadow: none; + -webkit-box-shadow: 0 0 0 50px #FFF inset; + box-shadow: 0 0 0 50px #FFF inset;*/ +} .login_main_message { text-align: center; max-width: 560px; @@ -1495,8 +1503,8 @@ table.login_table_securitycode tr td { border: 1px solid #f4f4f4; } #img_logo, .img-logo { - max-width: 200px; - max-height: 100px; + max-width: 170px; + max-height: 90px; } div.login_block { From 680c48d90ad1695a808ba8b92356e05e109b71b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 14:48:05 +0100 Subject: [PATCH 22/46] Fix error on expired tokens --- htdocs/admin/oauthlogintokens.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 93306e8d13c..2433575e553 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -175,18 +175,6 @@ if ($mode == 'setup' && $user->admin) $expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30)); } - // Token expired so we refresh it - if (is_object($tokenobj) && $expire) { - try { - // il faut sauvegarder le refresh token car le provider ne le donne qu'une seule fois - $refreshtoken = $tokenobj->getRefreshToken(); - $tokenobj = $apiService->refreshAccessToken($tokenobj); - $tokenobj->setRefreshToken($refreshtoken); - $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj); - } catch (Exception $e) { - setEventMessages($e->getMessage(), null, 'errors'); - } - } if ($key[1] != '' && $key[2] != '') { if (is_object($tokenobj)) { $refreshtoken = $tokenobj->getRefreshToken(); From 358616cda2dc2379848d097e3428d0c2a5bbd138 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 14:56:15 +0100 Subject: [PATCH 23/46] Fix link should be https --- htdocs/admin/tools/update.php | 2 +- htdocs/langs/en_US/admin.lang | 8 ++++---- htdocs/support/index.php | 16 +++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index e306862b67a..5cebb1dac4e 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -39,7 +39,7 @@ if (GETPOST('msg','alpha')) { } -$urldolibarr='http://www.dolibarr.org/downloads/'; +$urldolibarr='https://www.dolibarr.org/downloads/'; $urldolibarrmodules='https://www.dolistore.com/'; $urldolibarrthemes='https://www.dolistore.com/'; $dolibarrroot=preg_replace('/([\\/]+)$/i','',DOL_DOCUMENT_ROOT); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4f029afd8d8..77796bb5b02 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -279,7 +279,7 @@ ModuleFamilyInterface=Interfaces with external systems MenuHandlers=Menu handlers MenuAdmin=Menu editor DoNotUseInProduction=Do not use in production -ThisIsProcessToFollow=This is setup to process: +ThisIsProcessToFollow=This is steps to process: ThisIsAlternativeProcessToFollow=This is an alternative setup to process: StepNb=Step %s FindPackageFromWebSite=Find a package that provides feature you want (for example on official web site %s). @@ -1575,7 +1575,7 @@ BackupDumpWizard=Wizard to build database backup dump file SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason: SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is only manual steps a privileged user can do. InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file %s to allow this feature. -ConfFileMuseContainCustom=Installing an external module from application save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to have option
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='%s/custom'; +ConfFileMuseContainCustom=Installing an external module from application need to save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to have option
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='%s/custom'; HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (keep empty for no highlight) TextTitleColor=Color of page title @@ -1618,8 +1618,8 @@ ByDefaultInList=Show by default on list view YouUseLastStableVersion=You use the last stable version TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites) -ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. -ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. +ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of https://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. +ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of https://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. MultiPriceRuleDesc=When option "Several level of prices per product/service" is on, you can define different prices (one per price level) for each product. To save you time, you can enter here rule to have price for each level autocalculated according to price of first level, so you will have to enter only price for first level on each product. This page is here to save you time and can be usefull only if your prices for each leve are relative to first level. You can ignore this page in most cases. ModelModulesProduct=Templates for product documents ToGenerateCodeDefineAutomaticRuleFirst=To be able to generate automatically codes, you must first define a manager to auto define barcode number. diff --git a/htdocs/support/index.php b/htdocs/support/index.php index 947ae72e70c..a895cf5cb1e 100644 --- a/htdocs/support/index.php +++ b/htdocs/support/index.php @@ -86,13 +86,13 @@ print '
'; print ''; -//$urlwiki='http://wiki.dolibarr.org/index.php/List of Dolibarr partners and providers'; -$urlwiki='http://partners.dolibarr.org'; +$urlwiki='https://partners.dolibarr.org'; print ''; print ''; -//$urlwiki='http://wiki.dolibarr.org/index.php/List of Dolibarr partners and providers'; -$urlwiki='http://partners.dolibarr.org'; +$urlwiki='https://partners.dolibarr.org'; print '
'.$langs->trans($key['info']).''; + //var_dump($key); if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') { // Delete remote tokens @@ -187,7 +197,8 @@ if ($mode == 'setup' && $user->admin) // Token print '
'.$langs->trans("Token").''; + print ''; + $tokenobj=null; // Dolibarr storage $storage = new DoliStorage($db, $conf); try @@ -210,8 +221,6 @@ if ($mode == 'setup' && $user->admin) print '';*/ } print ''; - print '
-global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> -" name="password" class="flat input-icon-password" type="password" size="20" value="" tabindex="2" autocomplete="off" /> +" name="password" class="flat input-icon-password" type="password" size="20" value="" tabindex="2" autocomplete="global->MAIN_LOGIN_ENABLE_PASSWORD_AUTOCOMPLETE)?'off':'on'; ?>" />
'; print ''; print '
'; -$urlwiki='http://wiki.dolibarr.org'; -if (preg_match('/fr/i',$langs->defaultlang)) $urlwiki='http://wiki.dolibarr.org/index.php/Accueil'; -if (preg_match('/es/i',$langs->defaultlang)) $urlwiki='http://wiki.dolibarr.org/index.php/Portada'; +$urlwiki='https://wiki.dolibarr.org'; +if (preg_match('/fr/i',$langs->defaultlang)) $urlwiki='https://wiki.dolibarr.org/index.php/Accueil'; +if (preg_match('/es/i',$langs->defaultlang)) $urlwiki='https://wiki.dolibarr.org/index.php/Portada'; print '
'.$langs->trans("ForDocumentationSeeWiki",$urlwiki,$urlwiki); print '
'; -$urlforum='http://www.dolibarr.org/forum/'; -$urlforumlocal='http://www.dolibarr.org/forum/'; +$urlforum='https://www.dolibarr.org/forum/'; +$urlforumlocal='https://www.dolibarr.org/forum/'; if (preg_match('/fr/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.fr/forum/'; if (preg_match('/es/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.es/index.php/foro/'; if (preg_match('/it/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.it/forum/'; @@ -194,8 +194,7 @@ print '
'; print '
'; print ''; print '
'; @@ -229,8 +228,7 @@ print '
'; print '
'; print ''; print ''; -$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - -dol_syslog('htdocs/accountancy/customer/index.php'); -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - $i ++; - } - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "
'; From b21998d5060033d101e7fcccf8b0b25bf8d27eaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 15:56:04 +0100 Subject: [PATCH 24/46] Fix global checksum not visible on old versions. Link with checksum file to check was hardcoded. --- htdocs/admin/system/filecheck.php | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 1340b5ae3c1..c0ff5d75819 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -82,8 +82,8 @@ $xmlremote = GETPOST('xmlremote')?GETPOST('xmlremote'):'https://www.dolibarr.org // Test if remote test is ok $enableremotecheck = True; -if (preg_match('/beta|alpha/i', DOL_VERSION)) $enableremotecheck=False; - +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; +$enableremotecheck = true; print '
'; print $langs->trans("MakeIntegrityAnalysisFrom").':
'; @@ -101,7 +101,8 @@ else print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote.'
'; + print ' '.$langs->trans("RemoteSignature").' = '; + print '
'; } else { @@ -156,19 +157,25 @@ if ($xml) $file_list = array(); $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + print_fiche_titre($langs->trans("FilesMissing")); + print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''."\n"; $var = true; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); if (is_array($tmpfilelist) && count($tmpfilelist)) { + $i = 0; foreach ($tmpfilelist as $file) { + $i++; $var = !$var; print ''; + print '' . "\n"; print '' . "\n"; print '' . "\n"; print "\n"; @@ -176,15 +183,18 @@ if ($xml) } else { - print ''; + print ''; } print '
' . $langs->trans("FilesMissing") . '#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '
'.$i.''.$file['filename'].''.$file['expectedmd5'].'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print '
'; + print_fiche_titre($langs->trans("FilesUpdated")); + print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -194,10 +204,13 @@ if ($xml) $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); if (is_array($tmpfilelist2) && count($tmpfilelist2)) { + $i = 0; foreach ($tmpfilelist2 as $file) { + $i++; $var = !$var; print ''; + print '' . "\n"; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -241,14 +254,12 @@ if ($xml) //var_dump($checksumconcat); $checksumget = md5(join(',',$checksumconcat)); $checksumtoget = $xml->dolibarr_htdocs_dir_checksum; - if ($checksumtoget) - { - print '
'; - print ''.$langs->trans("GlobalChecksum").'
'; - print $langs->trans("ExpectedChecksum").' = '.$checksumtoget.'
'; - print $langs->trans("CurrentChecksum").' = '.$checksumget; - } - + + print '
'; + + print_fiche_titre($langs->trans("GlobalChecksum")).'
'; + print $langs->trans("ExpectedChecksum").' = '. ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")) .'
'; + print $langs->trans("CurrentChecksum").' = '.$checksumget; } From 8ee838c9c44e3ac1f8f752a71d44b85a4a688495 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 16:17:15 +0100 Subject: [PATCH 25/46] Minor fixes in accounting module. --- htdocs/accountancy/admin/accountmodel.php | 6 +- .../accountancy/bookkeeping/listbyaccount.php | 13 +- htdocs/accountancy/customer/index.php | 177 +++++++++--------- htdocs/accountancy/expensereport/index.php | 96 +++++----- htdocs/accountancy/supplier/index.php | 98 +++++----- 5 files changed, 193 insertions(+), 197 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d4b5407c912..ba2643a04b8 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -888,18 +888,18 @@ if ($id) { if ($value == 'country') { - print ''; } else { - print ''; + print ''; } } } if ($id == 4) print ''; - print ''; + print ''; print '\n"; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index ef5c512179a..e6499d23132 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -301,97 +301,96 @@ print "
' . $langs->trans("FilesUpdated") . '#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '' . $langs->trans("CurrentChecksum") . '' . $langs->trans("Size") . '
'.$i.''.$file['filename'].''.$file['expectedmd5'].''.$file['md5'].''; + print ''; print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 6308c2d3edc..ca6a3657774 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -235,9 +235,8 @@ print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" print "
' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . ''; print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); @@ -247,10 +246,10 @@ print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '  '; +print '  '; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print '
\n"; - - -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + $i ++; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + + if (! empty($conf->margin->enabled)) { + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; + } + } -print '
' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; - -if (! empty($conf->margin->enabled)) { - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - - dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; -} -print "
\n"; -print ''; llxFooter(); $db->close(); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index b4c5da80af4..b4d7c0bbb7a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -290,55 +290,55 @@ print "\n"; -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " ROUND(SUM(erd.total_ht),2) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND er.fk_statut > 0 "; + $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + + dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; } -print '' . $langs->trans("Total") . ''; - -$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " ROUND(SUM(erd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND er.fk_statut > 0 "; -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy - -dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - - - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; - } - print '' . price($row[13]) . ''; - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "\n"; llxFooter(); $db->close(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ef7d470bb07..a747342a508 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -289,58 +289,56 @@ print "\n"; - -print '
'; -print '
'; - - -print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - - - - -print "
\n"; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - print ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '
'; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " ROUND(SUM(ffd.total_ht),2) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND ff.fk_statut > 0 "; + $sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy + + dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; } -print '' . $langs->trans("Total") . ''; -$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; -for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " ROUND(SUM(ffd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND ff.fk_statut > 0 "; -$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy - -dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - - - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; - } - print '' . price($row[13]) . ''; - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "\n"; llxFooter(); $db->close(); From e6cdcfca006997df36eac2806e50ee2249c5fa87 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 16:47:11 +0100 Subject: [PATCH 26/46] Close #6240 --- htdocs/accountancy/customer/index.php | 33 ++++++++++++++++++++++++--- htdocs/accountancy/customer/list.php | 5 ++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index e6499d23132..dddc7c896c0 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -29,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Langs $langs->load("compta"); @@ -179,7 +180,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 1) print 'global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); @@ -222,6 +230,11 @@ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "' $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); @@ -273,6 +286,11 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; @@ -326,6 +344,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } dol_syslog('htdocs/accountancy/customer/index.php'); $resql = $db->query($sql); @@ -367,7 +390,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { @@ -388,7 +416,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } print "\n"; } - } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 7f214ffdf3c..dbb34299104 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -210,6 +210,11 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx",$search_vat,1); } +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); From 71d8a8175124c9b288ea25acc5171e1c81b5c985 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 17:05:55 +0100 Subject: [PATCH 27/46] Fix color green is reserved to say ok not for neutral messages. --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 75dc6b682d6..d72d303aa32 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3070,7 +3070,7 @@ div.info { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; - background: #E0EAE4; + background: #EaE4Ea; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a2e9b1ecc1f..409a902648e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2992,7 +2992,7 @@ div.info { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; - background: #E0EAE4; + background: #EaE4Ea; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } From 65854318490eaf3598297fb6906735a89466751b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 17:32:45 +0100 Subject: [PATCH 28/46] Fix css --- htdocs/loan/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index a03abce6350..aea84394c1c 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -139,7 +139,7 @@ if ($resql) print ''; print ''; print ' '; - print ''; + print ''; print ''; print ''; print ''; From 4c4aeba855ee7c22f5e43d4700104d9eb8ba7b5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 17:54:47 +0100 Subject: [PATCH 29/46] Fix project on loans --- htdocs/core/class/html.formprojet.class.php | 5 ++++- htdocs/langs/en_US/loan.lang | 1 + htdocs/loan/class/loan.class.php | 6 +++--- htdocs/loan/index.php | 2 +- htdocs/loan/payment/card.php | 2 +- htdocs/projet/element.php | 8 ++++---- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index e98d0018e7a..20eb2dd35cb 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -458,13 +458,16 @@ class FormProjets if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done) $linkedtothirdparty=false; - if (! in_array($table_element, array('don','expensereport_det','expensereport'))) $linkedtothirdparty=true; + if (! in_array($table_element, array('don','expensereport_det','expensereport','loan'))) $linkedtothirdparty=true; $sqlfilter=''; $projectkey="fk_projet"; //print $table_element; switch ($table_element) { + case "loan": + $sql = "SELECT t.rowid, t.label as ref"; + break; case "facture": $sql = "SELECT t.rowid, t.facnumber as ref"; break; diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index de0a6fd0295..b45a70dff72 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -43,6 +43,7 @@ LoanCalcDesc=This mortgage calculator can be used to figure out monthly p GoToInterest=%s will go towards INTEREST GoToPrincipal=%s will go towards PRINCIPAL YouWillSpend=You will spend %s in year %s +ListLoanAssociatedProject=List of loan associated with the project # Admin ConfigLoan=Configuration of the module loan LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 0ed39ead170..bb51cf3b8f1 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -24,8 +24,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -/** \class Loan - * \brief Class to manage loan +/** + * Loan */ class Loan extends CommonObject { @@ -404,7 +404,7 @@ class Loan extends CommonObject * @param int $maxlen Label max length * @return string Chaine with URL */ - function getLinkUrl($withpicto=0,$maxlen=0) + function getNomUrl($withpicto=0,$maxlen=0) { global $langs; diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index a03abce6350..289bd8dbee4 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -157,7 +157,7 @@ if ($resql) print ""; // Ref - print ''.$loan_static->getLinkUrl(1, 42).''; + print ''.$loan_static->getNomUrl(1, 42).''; // Label print ''.dol_trunc($obj->label,42).''; diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index c76b0565a3f..4a5faf4665f 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -231,7 +231,7 @@ if ($resql) // Ref print ''; $loan->fetch($objp->id); - print $loan->getLinkUrl(1); + print $loan->getNomUrl(1); print "\n"; // Label print ''.$objp->label.''; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 74cb6afec8c..77a6464e563 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -47,7 +47,7 @@ if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compt if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $langs->load("projects"); $langs->load("companies"); @@ -377,14 +377,14 @@ $listofreferent=array( 'title'=>"ListLoanAssociatedProject", 'class'=>'Loan', 'margin'=>'add', - 'table'=>'Loan', + 'table'=>'loan', 'datefieldname'=>'datestart', 'disableamount'=>0, 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid, 'lang'=>'loan', 'buttonnew'=>'AddLoan', - 'testnew'=>$user->rights->loan->creer, - 'test'=>$conf->loan->enabled && $user->rights->loan->lire), + 'testnew'=>$user->rights->loan->write, + 'test'=>$conf->loan->enabled && $user->rights->loan->read), 'project_task'=>array( 'name'=>"TaskTimeValorised", 'title'=>"ListTaskTimeUserProject", From 51b9802de40318908a310c5e06054475aa7925b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 20:42:35 +0100 Subject: [PATCH 30/46] NEW Hook to allow inserting custom product head #6001 --- htdocs/core/class/commonobject.class.php | 154 ++++++++++++----------- 1 file changed, 80 insertions(+), 74 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 98bf53743ba..89795e7df5d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3299,84 +3299,90 @@ abstract class CommonObject $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; - print ''; - - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; - - // Description - print ''.$langs->trans('Description').''; - - if ($this->element == 'supplier_proposal') - { - print ''.$langs->trans("SupplierProposalRefFourn").''; - } - - // VAT - print ''.$langs->trans('VAT').''; - - // Price HT - print ''.$langs->trans('PriceUHT').''; - - // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; - - if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; - - // Qty - print ''.$langs->trans('Qty').''; - - if($conf->global->PRODUCT_USE_UNITS) - { - print ''.$langs->trans('Unit').''; - } - - // Reduction short - print ''.$langs->trans('ReductionShort').''; - - if ($this->situation_cycle_ref) { - print '' . $langs->trans('Progress') . ''; - } - - if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) - { - if (!empty($user->rights->margins->creer)) - { - if ($conf->global->MARGIN_TYPE == "1") - print ''.$langs->trans('BuyingPrice').''; - else - print ''.$langs->trans('CostPrice').''; - } - - if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarginRate').''; - if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarkRate').''; - } - - // Total HT - print ''.$langs->trans('TotalHTShort').''; - - // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; - - if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; - - print ''; // No width to allow autodim - - print ''; - - print ''; - - print "\n"; - $num = count($this->lines); - $var = true; - $i = 0; - + //Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); + + $parameters = array('num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); + $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + print ''; + + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; + + // Description + print ''.$langs->trans('Description').''; + + if ($this->element == 'supplier_proposal') + { + print ''.$langs->trans("SupplierProposalRefFourn").''; + } + + // VAT + print ''.$langs->trans('VAT').''; + + // Price HT + print ''.$langs->trans('PriceUHT').''; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + + if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; + + // Qty + print ''.$langs->trans('Qty').''; + + if($conf->global->PRODUCT_USE_UNITS) + { + print ''.$langs->trans('Unit').''; + } + + // Reduction short + print ''.$langs->trans('ReductionShort').''; + + if ($this->situation_cycle_ref) { + print '' . $langs->trans('Progress') . ''; + } + + if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) + { + if (!empty($user->rights->margins->creer)) + { + if ($conf->global->MARGIN_TYPE == "1") + print ''.$langs->trans('BuyingPrice').''; + else + print ''.$langs->trans('CostPrice').''; + } + + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) + print ''.$langs->trans('MarginRate').''; + if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) + print ''.$langs->trans('MarkRate').''; + } + + // Total HT + print ''.$langs->trans('TotalHTShort').''; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + + if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; + + print ''; // No width to allow autodim + + print ''; + + print ''; + + print "\n"; + } + + $var = true; + $i = 0; foreach ($this->lines as $line) { @@ -3395,7 +3401,7 @@ abstract class CommonObject } else { - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); + $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line); $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } From 1b3af1df0798ff22fb446279de062266707a40f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:03:45 +0100 Subject: [PATCH 31/46] More space between text --- htdocs/theme/eldy/style.css.php | 2 ++ htdocs/theme/md/style.css.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d72d303aa32..a9f2b808de9 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -241,6 +241,7 @@ body { color: rgb(); font-size: px; + line-height: 130%; font-family: ; margin-top: 0; margin-bottom: 0; @@ -594,6 +595,7 @@ div.myavailability { .div-table-responsive { overflow-x: auto; min-height: 0.01%; + line-height: 100%; } /* Style used for full page tables with field selector and no content after table (priority before previous for such tables) */ div.fiche>form>div.div-table-responsive { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 409a902648e..eb46cb40b84 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -242,6 +242,7 @@ body { color: rgb(); font-size: px; font-family: ; + line-height: 130%; margin-top: 0; margin-bottom: 0; margin-right: 0; @@ -599,6 +600,7 @@ div.myavailability { .div-table-responsive { overflow-x: auto; min-height: 0.01%; + line-height: 100%; } /* Style used for full page tables with field selector and no content after table (priority before previous for such tables) */ div.fiche>form>div.div-table-responsive { From df9121d6fa3097987c56039188967a90192be07f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:33:13 +0100 Subject: [PATCH 32/46] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ce043d7f16b..5ccf4f08d35 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,7 +5737,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrits = explode('|',$crit); + $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); + $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); + $tmpcrits = explode('|',$tmpcrit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 5446ff667af08dacb1f9153c23d949d82cf73c1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:33:23 +0100 Subject: [PATCH 33/46] Fix translation --- htdocs/langs/en_US/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 185e1e49424..edd72899f3d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -788,8 +788,8 @@ SetRef=Set ref Select2ResultFoundUseArrows=Some results found. Use arrows to select. Select2NotFound=No result found Select2Enter=Enter -Select2MoreCharacter=or more characters

SEARCH PARAMETERS:
[without spaces]

| OR
* SEARCH ALL
-Select2MoreCharacters=or more characters +Select2MoreCharacter=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
+Select2MoreCharacters=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... SearchIntoThirdparties=Thirdparties From 37d158f15915aba6ea96823b6bef0a5a30bc5f2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:33:13 +0100 Subject: [PATCH 34/46] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb268ffa2d0..d38f765c6f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,7 +5737,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrits = explode('|',$crit); + $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); + $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); + $tmpcrits = explode('|',$tmpcrit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 163ee094ec2c082970e8f1aa199be1cba6b2d685 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:46:26 +0100 Subject: [PATCH 35/46] Revert "FIX Accept spaces around the | criteria" This reverts commit df9121d6fa3097987c56039188967a90192be07f. --- htdocs/core/lib/functions.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5ccf4f08d35..ce043d7f16b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,9 +5737,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); - $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); - $tmpcrits = explode('|',$tmpcrit); + $tmpcrits = explode('|',$crit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 2c1477ecea93d534b62d8bcce05e27c6c8007f6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:50:14 +0100 Subject: [PATCH 36/46] Revert "FIX Accept spaces around the | criteria" This reverts commit 37d158f15915aba6ea96823b6bef0a5a30bc5f2a. --- htdocs/core/lib/functions.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d38f765c6f5..bb268ffa2d0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,9 +5737,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); - $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); - $tmpcrits = explode('|',$tmpcrit); + $tmpcrits = explode('|',$crit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 785b2d46b316f7e89a4233bce13a930deff3eee9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 01:00:47 +0100 Subject: [PATCH 37/46] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ce043d7f16b..3cb4cc31093 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5677,7 +5677,7 @@ function dol_getmypid() * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" * If param $mode is 2, can contains a list of id separated by comma like "1,3,4" * @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') - * @param integer $nofirstand 1=Do now output the first 'AND' + * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query */ function natural_search($fields, $value, $mode=0, $nofirstand=0) @@ -5692,6 +5692,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } + + $value = preg_replace('/\s*\|\s*/','|', $value); + $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); From 76a53dfb7d32739171e31495e85939477549dec2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 01:00:47 +0100 Subject: [PATCH 38/46] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb268ffa2d0..2ce0bd1a524 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5677,7 +5677,7 @@ function dol_getmypid() * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" * If param $mode is 2, can contains a list of id separated by comma like "1,3,4" * @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') - * @param integer $nofirstand 1=Do now output the first 'AND' + * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query */ function natural_search($fields, $value, $mode=0, $nofirstand=0) @@ -5692,6 +5692,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } + + $value = preg_replace('/\s*\|\s*/','|', $value); + $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); From 8e615a83e5fe9f5ce594b89b61542a272c04a3c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 01:07:28 +0100 Subject: [PATCH 39/46] Better tooltip --- htdocs/langs/en_US/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index edd72899f3d..a4f396a43b8 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -788,8 +788,8 @@ SetRef=Set ref Select2ResultFoundUseArrows=Some results found. Use arrows to select. Select2NotFound=No result found Select2Enter=Enter -Select2MoreCharacter=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
-Select2MoreCharacters=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
+Select2MoreCharacter=or more characters

Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
+Select2MoreCharacters=or more characters

Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... SearchIntoThirdparties=Thirdparties From 41832a0c2657087d8eeea72fff1cc886e7e19585 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:20:29 +0100 Subject: [PATCH 40/46] Fix neutral color on login (no theme yet selected) --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d72d303aa32..6da8a7cf935 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -262,7 +262,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla input:focus, textarea:focus, button:focus, select:focus { /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #8091BF !important; + border-bottom: 1px solid #aaa !important; } textarea.cke_source:focus { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 409a902648e..a66727cb3db 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -262,7 +262,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla input:focus, textarea:focus, button:focus, select:focus { /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #8091BF !important; + border-bottom: 1px solid #aaa !important; } textarea.cke_source:focus { From 913df73ed918589d6e28fb05f9dc9abb5b677af9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:31:39 +0100 Subject: [PATCH 41/46] Fix css --- htdocs/theme/eldy/style.css.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6da8a7cf935..02460670217 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -261,8 +261,8 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla } input:focus, textarea:focus, button:focus, select:focus { - /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #aaa !important; + box-shadow: 0 0 4px #8091BF; + /* TODO Remove shadow on focus. Use instead border-bottom: 1px solid #aaa !important; To disable with select2 too. */ } textarea.cke_source:focus { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a66727cb3db..7a0d16e4743 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -261,8 +261,8 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla } input:focus, textarea:focus, button:focus, select:focus { - /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #aaa !important; + box-shadow: 0 0 4px #8091BF; + /* TODO Remove shadow on focus. Use instead border-bottom: 1px solid #aaa !important; To disable with select2 too. */ } textarea.cke_source:focus { From 1856b5cfb8790b47472295da1ddacbc62cbacb52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:50:43 +0100 Subject: [PATCH 42/46] Fix filter on status for third parties --- htdocs/societe/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9506c5ad6bd..8982d2db32d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -226,7 +226,7 @@ if (empty($reshook)) $search_idprof6=''; $search_type=''; $search_type_thirdparty=''; - $search_status=''; + $search_status=-1; $search_stcomm=''; $search_level_from=''; $search_level_to=''; @@ -413,7 +413,7 @@ if ($search_idprof6) $sql.= natural_search("s.idprof6",$search_idprof6); if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; -if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status); +if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status); if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= " AND s.barcode LIKE '%".$db->escape($search_barcode)."%'"; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; @@ -878,7 +878,7 @@ if (! empty($arrayfields['s.tms']['checked'])) if (! empty($arrayfields['s.status']['checked'])) { print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); print ''; } // Action column From dba777c57b1444737a95396aab33ee3e4b35f34f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 12:10:07 +0100 Subject: [PATCH 43/46] Fix missing field alias --- htdocs/societe/soc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 06413548d9a..020d0aad63f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -290,9 +290,8 @@ if (empty($reshook)) else { $object->name = GETPOST('name', 'alpha'); - $object->name_alias = GETPOST('name_alias'); } - + $object->name_alias = GETPOST('name_alias'); $object->address = GETPOST('address'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -920,7 +919,6 @@ else $("#radiocompany").click(function() { $(".individualline").hide(); $("#typent_id").val(0); - $("#name_alias").show(); $("#effectif_id").val(0); $("#TypeName").html(document.formsoc.ThirdPartyName.value); document.formsoc.private.value=0; @@ -928,7 +926,6 @@ else $("#radioprivate").click(function() { $(".individualline").show(); $("#typent_id").val(id_te_private); - $("#name_alias").hide(); $("#effectif_id").val(id_ef15); $("#TypeName").html(document.formsoc.LastName.value); document.formsoc.private.value=1; @@ -970,7 +967,7 @@ else print ''; print ''; print ''; - print ''; + print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; @@ -982,11 +979,11 @@ else print ''; if ($object->particulier || $private) { - print ''.$langs->trans('LastName','name').''; + print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').''; } else { - print ''.fieldLabel('ThirdPartyName','name').''; + print ''.fieldLabel('ThirdPartyName','name').''; } print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; print ''; From 62a668d8997a7eb26375f618f425da73f91c6415 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:02:17 +0100 Subject: [PATCH 44/46] Fix https link --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b6a5d904c34..92df8f48f05 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1025,7 +1025,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; // Displays title $appli=constant('DOL_APPLICATION_TITLE'); From 03aa8343fd1486733b657865b176a506bcd293e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:21:35 +0100 Subject: [PATCH 45/46] Fix css --- htdocs/cashdesk/tpl/facturation1.tpl.php | 18 +++++++++--------- htdocs/theme/eldy/style.css.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d20eb4c3299..208727a7644 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -106,23 +106,23 @@ $langs->load("cashdesk"); trans("VATRate"); ?> - + - + - + - + - + @@ -155,17 +155,17 @@ $langs->load("cashdesk");
trans("Amount"); ?> - +
- + - - +
trans("TotalTicket"); ?>trans("Received"); ?>trans("Change"); ?>
+
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 02460670217..1b5c36bb000 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4463,7 +4463,7 @@ border-top-right-radius: 6px; color: #fff; text-decoration: none; padding-top: 18px; - : 54px; + padding-left: 54px; font-size: 14px; height: 38px; } From fd008f88b100bcfc6918d3ec2e23969e783503b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:21:59 +0100 Subject: [PATCH 46/46] Add github tools --- dev/tools/github_authors_peryear.sh | 8 ++++++++ dev/tools/github_commits_perversion.sh | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 dev/tools/github_authors_peryear.sh create mode 100755 dev/tools/github_commits_perversion.sh diff --git a/dev/tools/github_authors_peryear.sh b/dev/tools/github_authors_peryear.sh new file mode 100755 index 00000000000..99b28d4d417 --- /dev/null +++ b/dev/tools/github_authors_peryear.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FROM=2016-01-01 +TO=2016-12-31 + +echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" +git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l + diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh new file mode 100755 index 00000000000..40ddafee617 --- /dev/null +++ b/dev/tools/github_commits_perversion.sh @@ -0,0 +1,15 @@ +#/bin/bash +Releases=("3.8" "3.9" "4.0" "5.0", "develop") +Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") +let "counter = 1" + +for i in "${Releases[@]}" +do + git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]} + echo -n "Total $i: " + git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l + echo "=======================" + echo + let "counter +=1" +done +