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 42f7e8fd76c01..5f5581a6d4856 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 64d1de5dc29c4..c6d8147fe4716 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 b24f9c75253c1..8d8c938f64143 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -127,7 +127,7 @@
$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 @@
$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 @@
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 ' |
';
}
@@ -473,11 +473,11 @@
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 ' | ';
diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php
index 8ed6e682ce6c1..ac0062d3ed919 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 @@ function __construct($db)
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 @@ function fetch($id)
$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 @@ function fetch($id)
function create($user)
{
global $conf;
-
+
$error=0;
$now=dol_now();
@@ -143,7 +143,7 @@ function create($user)
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 @@ function create($user)
$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 @@ function create($user)
$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 @@ function update($user)
$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 @@ function LibStatut($statut,$mode=0,$alreadypaid=-1)
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 958f0b242a255..9abcc1d0771a8 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -47,6 +47,7 @@
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->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 @@
'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 @@
$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action);
if(!empty($hookmanager->resArray)) {
-
+
$listofreferent = array_merge($listofreferent, $hookmanager->resArray);
-
+
}
if ($action=="addelement")
@@ -490,7 +505,7 @@
$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 @@
$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 @@
{
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 @@
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 @@
}
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 @@
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);
}