Merge branch 'develop' of https://github.com/Franck-MOREAU/dolibarr into
Franck-MOREAU-develop Conflicts: htdocs/core/lib/functions.lib.php htdocs/install/mysql/migration/4.0.0-5.0.0.sql htdocs/loan/card.php htdocs/loan/class/loan.class.php htdocs/projet/element.php
This commit is contained in:
commit
e9853f3cd7
@ -223,7 +223,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Categorisation dans projet
|
// Link to a project
|
||||||
else if ($action == 'classin' && $user->rights->commande->creer)
|
else if ($action == 'classin' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
$object->setProject(GETPOST('projectid'));
|
$object->setProject(GETPOST('projectid'));
|
||||||
|
|||||||
@ -79,7 +79,7 @@ class FormProjets
|
|||||||
$project->fetch($selected);
|
$project->fetch($selected);
|
||||||
$selected_input_value=$project->ref;
|
$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(
|
$out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
|
||||||
// 'update' => array(
|
// 'update' => array(
|
||||||
// 'projectid' => 'id'
|
// 'projectid' => 'id'
|
||||||
|
|||||||
@ -43,3 +43,6 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
|
|||||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30);
|
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30);
|
||||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30);
|
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_loan ADD COLUMN fk_projet integer DEFAULT NULL;
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,9 @@ create table llx_loan
|
|||||||
accountancy_account_insurance varchar(32),
|
accountancy_account_insurance varchar(32),
|
||||||
accountancy_account_interest varchar(32),
|
accountancy_account_interest varchar(32),
|
||||||
|
|
||||||
|
fk_projet integer DEFAULT NULL,
|
||||||
|
|
||||||
fk_user_author integer DEFAULT NULL,
|
fk_user_author integer DEFAULT NULL,
|
||||||
fk_user_modif integer DEFAULT NULL,
|
fk_user_modif integer DEFAULT NULL
|
||||||
active tinyint DEFAULT 1 NOT NULL
|
active tinyint DEFAULT 1 NOT NULL
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.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.'/core/lib/accounting.lib.php';
|
||||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||||
|
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("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -45,148 +47,167 @@ $result = restrictedArea($user, 'loan', $id, '','');
|
|||||||
|
|
||||||
$object = new Loan($db);
|
$object = new Loan($db);
|
||||||
|
|
||||||
|
$hookmanager->initHooks(array('loancard','globalcard'));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Classify paid
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($action == 'confirm_paid' && $confirm == 'yes')
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
// Classify paid
|
||||||
$result = $object->set_paid($user);
|
if ($action == 'confirm_paid' && $confirm == 'yes')
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
$object->fetch($id);
|
||||||
}
|
$result = $object->set_paid($user);
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($loan->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete loan
|
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
|
||||||
{
|
|
||||||
$object->fetch($id);
|
|
||||||
$result=$object->delete($user);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
|
||||||
header("Location: index.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($loan->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add loan
|
|
||||||
if ($action == 'add' && $user->rights->loan->write)
|
|
||||||
{
|
|
||||||
if (! $cancel)
|
|
||||||
{
|
|
||||||
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
|
|
||||||
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
|
|
||||||
$capital = price2num(GETPOST('capital'));
|
|
||||||
|
|
||||||
if (! $datestart)
|
|
||||||
{
|
|
||||||
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 (! $capital)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
|
||||||
$action = 'create';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$object->label = GETPOST('label');
|
|
||||||
$object->fk_bank = GETPOST('accountid');
|
|
||||||
$object->capital = $capital;
|
|
||||||
$object->datestart = $datestart;
|
|
||||||
$object->dateend = $dateend;
|
|
||||||
$object->nbterm = GETPOST('nbterm');
|
|
||||||
$object->rate = GETPOST('rate');
|
|
||||||
$object->note_private = GETPOST('note_private');
|
|
||||||
$object->note_public = GETPOST('note_public');
|
|
||||||
|
|
||||||
$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))
|
|
||||||
{
|
|
||||||
$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->capital = price2num(GETPOST("capital"));
|
|
||||||
$object->nbterm = GETPOST("nbterm");
|
|
||||||
$object->rate = GETPOST("rate");
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $object->update($user);
|
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($loan->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete loan
|
||||||
|
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||||
|
{
|
||||||
|
$object->fetch($id);
|
||||||
|
$result=$object->delete($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($loan->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add loan
|
||||||
|
if ($action == 'add' && $user->rights->loan->write)
|
||||||
|
{
|
||||||
|
if (! $cancel)
|
||||||
|
{
|
||||||
|
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
|
||||||
|
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
|
||||||
|
$capital = price2num(GETPOST('capital'));
|
||||||
|
|
||||||
|
if (! $datestart)
|
||||||
|
{
|
||||||
|
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 (! $capital)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
||||||
|
$action = 'create';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$object->label = GETPOST('label');
|
||||||
|
$object->fk_bank = GETPOST('accountid');
|
||||||
|
$object->capital = $capital;
|
||||||
|
$object->datestart = $datestart;
|
||||||
|
$object->dateend = $dateend;
|
||||||
|
$object->nbterm = GETPOST('nbterm');
|
||||||
|
$object->rate = GETPOST('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 ($result > 0)
|
||||||
|
{
|
||||||
|
$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->capital = price2num(GETPOST("capital"));
|
||||||
|
$object->nbterm = GETPOST("nbterm");
|
||||||
|
$object->rate = GETPOST("rate");
|
||||||
|
}
|
||||||
|
|
||||||
|
$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);
|
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Link to a project
|
||||||
|
if ($action == 'classin' && $user->rights->loan->write)
|
||||||
|
{
|
||||||
|
$object->fetch($id);
|
||||||
|
$result = $object->setProject(GETPOST('projectid'));
|
||||||
|
if ($result < 0)
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setlabel' && $user->rights->loan->write)
|
||||||
{
|
{
|
||||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
$object->fetch($id);
|
||||||
exit;
|
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
|
||||||
|
if ($result < 0)
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setlabel' && $user->rights->loan->write)
|
|
||||||
{
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
|
|
||||||
if ($result < 0)
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
|
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
|
||||||
|
|
||||||
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
|
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
|
||||||
@ -250,6 +271,21 @@ if ($action == 'create')
|
|||||||
// Rate
|
// Rate
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Rate").'</td><td><input name="rate" size="5" value="' . GETPOST("rate") . '"> %</td></tr>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("Rate").'</td><td><input name="rate" size="5" value="' . GETPOST("rate") . '"> %</td></tr>';
|
||||||
|
|
||||||
|
// Project
|
||||||
|
if (! empty($conf->projet->enabled))
|
||||||
|
{
|
||||||
|
$formproject=new FormProjets($db);
|
||||||
|
|
||||||
|
// Projet associe
|
||||||
|
$langs->load("projects");
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||||
|
|
||||||
|
$numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1);
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Note Private
|
// Note Private
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
|
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
|
||||||
@ -354,13 +390,47 @@ if ($id > 0)
|
|||||||
|
|
||||||
dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill');
|
dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill');
|
||||||
|
|
||||||
|
// Loan card
|
||||||
|
|
||||||
|
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
|
||||||
|
|
||||||
$morehtmlref='<div class="refidno">';
|
$morehtmlref='<div class="refidno">';
|
||||||
// Ref loan
|
// Ref loan
|
||||||
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
|
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
|
||||||
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
|
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
|
||||||
$morehtmlref.='</div>';
|
// Project
|
||||||
|
if (! empty($conf->projet->enabled))
|
||||||
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
|
{
|
||||||
|
$langs->load("projects");
|
||||||
|
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||||
|
if ($user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
if ($action != 'classify')
|
||||||
|
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
|
if ($action == 'classify') {
|
||||||
|
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||||
|
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||||
|
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||||
|
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||||
|
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||||
|
$morehtmlref.='</form>';
|
||||||
|
} else {
|
||||||
|
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (! empty($object->fk_project)) {
|
||||||
|
$proj = new Project($db);
|
||||||
|
$proj->fetch($object->fk_project);
|
||||||
|
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||||
|
$morehtmlref.=$proj->ref;
|
||||||
|
$morehtmlref.='</a>';
|
||||||
|
} else {
|
||||||
|
$morehtmlref.='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$morehtmlref.='</div>';
|
||||||
|
|
||||||
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
||||||
|
|
||||||
@ -468,6 +538,7 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
// print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
// print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
||||||
|
|
||||||
@ -572,33 +643,37 @@ if ($id > 0)
|
|||||||
*/
|
*/
|
||||||
if ($action != 'edit')
|
if ($action != 'edit')
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
if ($user->rights->loan->write)
|
if ($user->rights->loan->write)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit payment
|
// Emit payment
|
||||||
if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classify 'paid'
|
// Classify 'paid'
|
||||||
if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write)
|
if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid">'.$langs->trans("ClassifyPaid").'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid">'.$langs->trans("ClassifyPaid").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($user->rights->loan->delete)
|
if ($user->rights->loan->delete)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -32,6 +32,7 @@ class Loan extends CommonObject
|
|||||||
public $element='loan';
|
public $element='loan';
|
||||||
public $table='loan';
|
public $table='loan';
|
||||||
public $table_element='loan';
|
public $table_element='loan';
|
||||||
|
|
||||||
public $picto = 'bill';
|
public $picto = 'bill';
|
||||||
|
|
||||||
public $rowid;
|
public $rowid;
|
||||||
@ -51,6 +52,7 @@ class Loan extends CommonObject
|
|||||||
public $fk_bank;
|
public $fk_bank;
|
||||||
public $fk_user_creat;
|
public $fk_user_creat;
|
||||||
public $fk_user_modif;
|
public $fk_user_modif;
|
||||||
|
public $fk_project;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +75,7 @@ class Loan extends CommonObject
|
|||||||
function fetch($id)
|
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 = "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_projet as fk_project";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l";
|
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l";
|
||||||
$sql.= " WHERE l.rowid = ".$id;
|
$sql.= " WHERE l.rowid = ".$id;
|
||||||
|
|
||||||
@ -100,6 +102,7 @@ class Loan extends CommonObject
|
|||||||
$this->account_capital = $obj->accountancy_account_capital;
|
$this->account_capital = $obj->accountancy_account_capital;
|
||||||
$this->account_insurance = $obj->accountancy_account_insurance;
|
$this->account_insurance = $obj->accountancy_account_insurance;
|
||||||
$this->account_interest = $obj->accountancy_account_interest;
|
$this->account_interest = $obj->accountancy_account_interest;
|
||||||
|
$this->fk_project = $obj->fk_project;
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return 1;
|
return 1;
|
||||||
@ -142,6 +145,7 @@ class Loan extends CommonObject
|
|||||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
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_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_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
|
// Check parameters
|
||||||
if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend))
|
if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend))
|
||||||
@ -157,9 +161,9 @@ class Loan extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public";
|
$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.= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
|
||||||
$sql.= " ,datec, fk_user_author)";
|
$sql.= " datec, fk_projet, fk_user_author)";
|
||||||
$sql.= " VALUES ('".$this->db->escape($this->label)."',";
|
$sql.= " VALUES ('".$this->db->escape($this->label)."',";
|
||||||
$sql.= " '".$this->db->escape($this->fk_bank)."',";
|
$sql.= " '".$this->db->escape($this->fk_bank)."',";
|
||||||
$sql.= " '".price2num($newcapital)."',";
|
$sql.= " '".price2num($newcapital)."',";
|
||||||
@ -174,6 +178,7 @@ class Loan extends CommonObject
|
|||||||
$sql.= " '".$this->db->escape($this->account_interest)."',";
|
$sql.= " '".$this->db->escape($this->account_interest)."',";
|
||||||
$sql.= " ".$conf->entity.",";
|
$sql.= " ".$conf->entity.",";
|
||||||
$sql.= " '".$this->db->idate($now)."',";
|
$sql.= " '".$this->db->idate($now)."',";
|
||||||
|
$sql.= " ".(empty($this->fk_project)?'NULL':$this->fk_project).",";
|
||||||
$sql.= " ".$user->id;
|
$sql.= " ".$user->id;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
@ -282,6 +287,7 @@ class Loan extends CommonObject
|
|||||||
$sql.= " capital='".price2num($this->db->escape($this->capital))."',";
|
$sql.= " capital='".price2num($this->db->escape($this->capital))."',";
|
||||||
$sql.= " datestart='".$this->db->idate($this->datestart)."',";
|
$sql.= " datestart='".$this->db->idate($this->datestart)."',";
|
||||||
$sql.= " dateend='".$this->db->idate($this->dateend)."',";
|
$sql.= " dateend='".$this->db->idate($this->dateend)."',";
|
||||||
|
$sql.= " fk_projet=".(empty($this->fk_project)?'NULL':$this->fk_project).",";
|
||||||
$sql.= " fk_user_modif = ".$user->id;
|
$sql.= " fk_user_modif = ".$user->id;
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ $htmlname=GETPOST('htmlname','alpha');
|
|||||||
$socid=GETPOST('socid','int');
|
$socid=GETPOST('socid','int');
|
||||||
$action=GETPOST('action', 'alpha');
|
$action=GETPOST('action', 'alpha');
|
||||||
$id=GETPOST('id', 'int');
|
$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):''));
|
$searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):''));
|
||||||
|
|
||||||
$form = new FormProjets($db);
|
$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();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -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->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->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->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("projects");
|
||||||
$langs->load("companies");
|
$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->deplacement->enabled)) $langs->load("trips");
|
||||||
if (! empty($conf->expensereport->enabled)) $langs->load("trips");
|
if (! empty($conf->expensereport->enabled)) $langs->load("trips");
|
||||||
if (! empty($conf->don->enabled)) $langs->load("donations");
|
if (! empty($conf->don->enabled)) $langs->load("donations");
|
||||||
|
if (! empty($conf->loan->enabled)) $langs->load("loan");
|
||||||
|
|
||||||
$id=GETPOST('id','int');
|
$id=GETPOST('id','int');
|
||||||
$ref=GETPOST('ref','alpha');
|
$ref=GETPOST('ref','alpha');
|
||||||
@ -370,6 +372,19 @@ $listofreferent=array(
|
|||||||
'buttonnew'=>'AddDonation',
|
'buttonnew'=>'AddDonation',
|
||||||
'testnew'=>$user->rights->don->creer,
|
'testnew'=>$user->rights->don->creer,
|
||||||
'test'=>$conf->don->enabled && $user->rights->don->lire),
|
'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),
|
||||||
'project_task'=>array(
|
'project_task'=>array(
|
||||||
'name'=>"TaskTimeValorised",
|
'name'=>"TaskTimeValorised",
|
||||||
'title'=>"ListTaskTimeUserProject",
|
'title'=>"ListTaskTimeUserProject",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user