Various fix on Loan and project link
This commit is contained in:
parent
f97bab6fb8
commit
a251f0df51
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$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 '</td></tr>';
|
||||
}
|
||||
@ -473,11 +473,11 @@ if ($id > 0)
|
||||
print '</td><td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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 '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user