NEW: Add project and Hook to Loan
BUG: Correct discard_closed parametters management in project
This commit is contained in:
parent
bfd1ce0095
commit
081be37787
@ -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'
|
||||||
|
|||||||
@ -221,4 +221,4 @@ drop table tmp_links_double;
|
|||||||
|
|
||||||
ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label);
|
ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label);
|
||||||
|
|
||||||
|
ALTER TABLE llx_loan ADD COLUMN fk_project integer DEFAULT NULL;
|
||||||
|
|||||||
@ -47,5 +47,6 @@ create table llx_loan
|
|||||||
|
|
||||||
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,
|
||||||
|
fk_project integer DEFAULT NULL
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -28,6 +28,11 @@ 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';
|
||||||
|
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("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -45,134 +50,143 @@ $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');
|
||||||
{
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->set_paid($user);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($loan->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete loan
|
if (empty($reshook))
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
// Classify paid
|
||||||
$result=$object->delete($user);
|
if ($action == 'confirm_paid' && $confirm == 'yes')
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
$object->fetch($id);
|
||||||
header("Location: index.php");
|
$result = $object->set_paid($user);
|
||||||
exit;
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($loan->error, null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($loan->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add loan
|
// Delete loan
|
||||||
if ($action == 'add' && $user->rights->loan->write)
|
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||||
{
|
|
||||||
if (! $cancel)
|
|
||||||
{
|
{
|
||||||
$datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]);
|
$object->fetch($id);
|
||||||
$dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
|
$result=$object->delete($user);
|
||||||
|
if ($result > 0)
|
||||||
if (! $datestart)
|
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
|
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
||||||
$action = 'create';
|
header("Location: index.php");
|
||||||
}
|
exit;
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
$object->label = $_POST["label"];
|
setEventMessages($loan->error, null, 'errors');
|
||||||
$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');
|
|
||||||
|
|
||||||
$accountancy_account_capital = GETPOST('accountancy_account_capital');
|
// Add loan
|
||||||
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
|
if ($action == 'add' && $user->rights->loan->write)
|
||||||
$accountancy_account_interest = GETPOST('accountancy_account_interest');
|
{
|
||||||
|
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 (! $datestart)
|
||||||
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');
|
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
|
||||||
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->label = GETPOST("label");
|
header("Location: index.php");
|
||||||
$object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
|
exit();
|
||||||
$object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
|
|
||||||
$object->nbterm = GETPOST("nbterm");
|
|
||||||
$object->rate = GETPOST("rate");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$result = $object->update($user);
|
// Update record
|
||||||
|
else if ($action == 'update' && $user->rights->loan->write)
|
||||||
|
{
|
||||||
|
if (! $cancel)
|
||||||
|
{
|
||||||
|
$result = $object->fetch($id);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($object->fetch($id))
|
||||||
{
|
{
|
||||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
$object->label = GETPOST("label");
|
||||||
exit;
|
$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'));
|
||||||
else
|
$object->nbterm = GETPOST("nbterm");
|
||||||
{
|
$object->rate = GETPOST("rate");
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
$object->fk_project = GETPOST("fk_project");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
$result = $object->update($user);
|
||||||
{
|
|
||||||
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
if ($result > 0)
|
||||||
exit;
|
{
|
||||||
}
|
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
|
* View
|
||||||
*/
|
*/
|
||||||
@ -240,6 +254,20 @@ 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>';
|
||||||
@ -283,8 +311,8 @@ if ($action == 'create')
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
|
print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else // For external software
|
else // For external software
|
||||||
{
|
{
|
||||||
// Accountancy_account_capital
|
// Accountancy_account_capital
|
||||||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
||||||
@ -300,11 +328,11 @@ if ($action == 'create')
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans("LoanAccountancyInterestCode").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("LoanAccountancyInterestCode").'</td>';
|
||||||
print '<td><input name="accountancy_account_interest" size="16" value="'.$object->accountancy_account_interest.'">';
|
print '<td><input name="accountancy_account_interest" size="16" value="'.$object->accountancy_account_interest.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
print '<div align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
print '<div align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
||||||
@ -438,6 +466,23 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// projet
|
||||||
|
if (! empty($conf->projet->enabled)){
|
||||||
|
print '<tr><td class="nowrap">';
|
||||||
|
print $langs->trans("Project");
|
||||||
|
print '</td><td>';
|
||||||
|
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 '</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>';
|
||||||
|
|
||||||
@ -445,7 +490,7 @@ if ($id > 0)
|
|||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'edit')
|
if ($action == 'edit')
|
||||||
{
|
{
|
||||||
print '<div align="center">';
|
print '<div align="center">';
|
||||||
@ -455,7 +500,7 @@ if ($id > 0)
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '</form><br><br>';
|
print '</form><br><br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
|
|
||||||
@ -537,33 +582,38 @@ 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
|
||||||
|
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>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classify 'paid'
|
||||||
|
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>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Classify 'paid'
|
|
||||||
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>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 "</div>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -50,6 +50,7 @@ class Loan extends CommonObject
|
|||||||
var $fk_bank;
|
var $fk_bank;
|
||||||
var $fk_user_creat;
|
var $fk_user_creat;
|
||||||
var $fk_user_modif;
|
var $fk_user_modif;
|
||||||
|
var $fk_project;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +73,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_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;
|
||||||
|
|
||||||
@ -99,6 +100,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;
|
||||||
@ -141,6 +143,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))
|
||||||
@ -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 = "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_project,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)."',";
|
||||||
@ -173,6 +176,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.= " '".$this->fk_project."',";
|
||||||
$sql.= " ".$user->id;
|
$sql.= " ".$user->id;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
@ -280,6 +284,7 @@ class Loan extends CommonObject
|
|||||||
$sql.= " SET label='".$this->db->escape($this->label)."',";
|
$sql.= " SET label='".$this->db->escape($this->label)."',";
|
||||||
$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_project='".$this->db->escape($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();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user