From 081be37787e745c96f5806237a511766522d0bc7 Mon Sep 17 00:00:00 2001 From: moreauf Date: Mon, 14 Nov 2016 19:25:50 +0100 Subject: [PATCH 1/4] 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 3/4] 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 2/4] 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;
'.$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 '