mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
code syntax hrm imports install intracommreport loan directory
This commit is contained in:
parent
c4e98486f7
commit
6cef78befb
|
|
@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
|
|||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'hrm'));
|
||||
|
||||
if (!$user->admin)
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
|
@ -52,8 +53,12 @@ llxHeader('', $langs->trans("Establishments"));
|
|||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) $sortfield = "e.rowid";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "e.rowid";
|
||||
}
|
||||
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
|
|
@ -79,8 +84,7 @@ $sql .= $db->order($sortfield, $sortorder);
|
|||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
|
@ -95,12 +99,10 @@ if ($result)
|
|||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.status", "", "", '', $sortfield, $sortorder, 'right ');
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
$establishmentstatic = new Establishment($db);
|
||||
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$establishmentstatic->id = $obj->rowid;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'hrm'));
|
||||
|
||||
if (!$user->admin)
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,9 @@ class Establishment extends CommonObject
|
|||
$this->zip = trim($this->zip);
|
||||
$this->town = trim($this->town);
|
||||
|
||||
if (empty($this->ref)) $this->ref = '(PROV)';
|
||||
if (empty($this->ref)) {
|
||||
$this->ref = '(PROV)';
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
|
@ -248,8 +250,7 @@ class Establishment extends CommonObject
|
|||
global $langs;
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->label))
|
||||
{
|
||||
if (empty($this->label)) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -296,8 +297,7 @@ class Establishment extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
|
@ -334,8 +334,7 @@ class Establishment extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -367,8 +366,7 @@ class Establishment extends CommonObject
|
|||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_OPEN] = $langs->trans('Open');
|
||||
|
|
@ -378,8 +376,12 @@ class Establishment extends CommonObject
|
|||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
if ($status == self::STATUS_OPEN) $statusType = 'status4';
|
||||
if ($status == self::STATUS_CLOSED) $statusType = 'status6';
|
||||
if ($status == self::STATUS_OPEN) {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
if ($status == self::STATUS_CLOSED) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
|
@ -400,22 +402,18 @@ class Establishment extends CommonObject
|
|||
dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_mod)
|
||||
{
|
||||
if ($obj->fk_user_mod) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_mod);
|
||||
$this->user_modification = $muser;
|
||||
|
|
@ -449,9 +447,15 @@ class Establishment extends CommonObject
|
|||
$label = '<u>'.$langs->trans("Establishment").'</u>';
|
||||
$label .= '<br>'.$langs->trans("Label").': '.$this->label;
|
||||
|
||||
if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) $result .= $link.$this->label.$linkend;
|
||||
if ($withpicto) {
|
||||
$result .= ($link.img_object($label, $picto).$linkend);
|
||||
}
|
||||
if ($withpicto && $withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $link.$this->label.$linkend;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -465,10 +469,14 @@ class Establishment extends CommonObject
|
|||
global $mysoc;
|
||||
|
||||
// We return country code of bank account
|
||||
if (!empty($this->country_code)) return $this->country_code;
|
||||
if (!empty($this->country_code)) {
|
||||
return $this->country_code;
|
||||
}
|
||||
|
||||
// We return country code of managed company
|
||||
if (!empty($mysoc->country_code)) return $mysoc->country_code;
|
||||
if (!empty($mysoc->country_code)) {
|
||||
return $mysoc->country_code;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
|||
$langs->loadLangs(array('admin', 'hrm'));
|
||||
|
||||
// Security check
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
|
@ -44,7 +46,9 @@ static $tmpstatus2label = array(
|
|||
'1'=>'OpenEtablishment'
|
||||
);
|
||||
$status2label = array('');
|
||||
foreach ($tmpstatus2label as $key => $val) $status2label[$key] = $langs->trans($val);
|
||||
foreach ($tmpstatus2label as $key => $val) {
|
||||
$status2label[$key] = $langs->trans($val);
|
||||
}
|
||||
|
||||
$object = new Establishment($db);
|
||||
|
||||
|
|
@ -56,31 +60,25 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
|||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == "yes")
|
||||
{
|
||||
if ($action == 'confirm_delete' && $confirm == "yes") {
|
||||
$result = $object->delete($id);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ../admin/admin_establishment.php");
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'add')
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
} elseif ($action == 'add') {
|
||||
if (!$cancel) {
|
||||
$error = 0;
|
||||
|
||||
$object->label = GETPOST('label', 'alpha');
|
||||
if (empty($object->label))
|
||||
{
|
||||
if (empty($object->label)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
if (empty($error)) {
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
|
|
@ -92,8 +90,7 @@ if ($action == 'confirm_delete' && $confirm == "yes")
|
|||
|
||||
$id = $object->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -106,11 +103,8 @@ if ($action == 'confirm_delete' && $confirm == "yes")
|
|||
header("Location: ../admin/admin_establishment.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Update record
|
||||
elseif ($action == 'update')
|
||||
{
|
||||
} elseif ($action == 'update') {
|
||||
// Update record
|
||||
$error = 0;
|
||||
|
||||
if (!$cancel) {
|
||||
|
|
@ -120,8 +114,7 @@ elseif ($action == 'update')
|
|||
$error++;
|
||||
}
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
if (empty($error)) {
|
||||
$object->label = GETPOST('label', 'alphanohtml');
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
|
|
@ -133,8 +126,7 @@ elseif ($action == 'update')
|
|||
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -159,8 +151,7 @@ $formcompany = new FormCompany($db);
|
|||
/*
|
||||
* Action create
|
||||
*/
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewEstablishment"));
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
|
|
@ -228,7 +219,9 @@ if ($action == 'create')
|
|||
print '<td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : ($object->country_id ? $object->country_id : $mysoc->country_id), 'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
|
@ -253,15 +246,12 @@ if ($action == 'create')
|
|||
}
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
if (($id || $ref) && $action == 'edit') {
|
||||
$result = $object->fetch($id);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$head = establishment_prepare_head($object);
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building');
|
||||
|
||||
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
|
|
@ -284,12 +274,12 @@ if (($id || $ref) && $action == 'edit')
|
|||
|
||||
// Entity
|
||||
/*
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $object->entity > 0 ? $object->entity : $conf->entity;
|
||||
print '</td></tr>';
|
||||
}*/
|
||||
print '</td></tr>';
|
||||
}*/
|
||||
|
||||
// Address
|
||||
print '<tr><td>'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
|
||||
|
|
@ -313,7 +303,9 @@ if (($id || $ref) && $action == 'edit')
|
|||
print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $form->select_country($object->country_id, 'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
|
@ -334,19 +326,19 @@ if (($id || $ref) && $action == 'edit')
|
|||
|
||||
print '</form>';
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
|
||||
{
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
$head = establishment_prepare_head($object);
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building');
|
||||
|
||||
// Confirmation to delete
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteEstablishment"), $langs->trans("ConfirmDeleteEstablishment"), "confirm_delete");
|
||||
}
|
||||
|
||||
|
|
@ -404,8 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Country").'</td>';
|
||||
print '<td>';
|
||||
if ($object->country_id > 0)
|
||||
{
|
||||
if ($object->country_id > 0) {
|
||||
$img = picto_from_langcode($object->country_code);
|
||||
print $img ? $img.' ' : '';
|
||||
print getCountry($object->getCountryCode(), 0, $db);
|
||||
|
|
@ -421,8 +412,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print dol_get_fiche_end();
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
* Barre d'actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ $backtopage = GETPOST('backtopage', 'alpha');
|
|||
|
||||
if (GETPOST('actioncode', 'array')) {
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
if (!count($actioncode)) $actioncode = '0';
|
||||
if (!count($actioncode)) {
|
||||
$actioncode = '0';
|
||||
}
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
|
|
@ -47,12 +49,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = 'a.datep,a.id';
|
||||
if (!$sortorder) $sortorder = 'DESC,DESC';
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'a.datep,a.id';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC,DESC';
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Establishment($db);
|
||||
|
|
@ -64,7 +72,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
|||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
|
||||
}
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->socid > 0) accessforbidden();
|
||||
|
|
@ -80,20 +90,19 @@ $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_
|
|||
|
||||
$parameters = array('id'=>$id);
|
||||
$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');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
|
|
@ -107,14 +116,15 @@ if (empty($reshook))
|
|||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
if ($object->id > 0) {
|
||||
$title = $langs->trans("Agenda");
|
||||
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = establishment_prepare_head($object);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
if ($conf->deplacement->enabled) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
}
|
||||
if ($conf->expensereport->enabled) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
|
||||
|
|
@ -47,9 +51,13 @@ $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes'));
|
|||
$socid = GETPOST("socid", "int");
|
||||
|
||||
// Protection if external user
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1;
|
||||
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
|
||||
$setupcompanynotcomplete = 1;
|
||||
}
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
$holidaystatic = new Holiday($db);
|
||||
|
|
@ -63,8 +71,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
|||
*/
|
||||
|
||||
// Update sold
|
||||
if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete))
|
||||
{
|
||||
if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) {
|
||||
$result = $holiday->updateBalance();
|
||||
}
|
||||
|
||||
|
|
@ -81,8 +88,7 @@ llxHeader('', $langs->trans('HRMArea'));
|
|||
print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm');
|
||||
|
||||
|
||||
if (!empty($setupcompanynotcomplete))
|
||||
{
|
||||
if (!empty($setupcompanynotcomplete)) {
|
||||
$langs->load("errors");
|
||||
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
|
||||
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
|
||||
|
|
@ -94,36 +100,34 @@ if (!empty($setupcompanynotcomplete))
|
|||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
|
||||
{
|
||||
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
|
||||
{
|
||||
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
|
||||
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) {
|
||||
$langs->load("holiday");
|
||||
$listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP');
|
||||
}
|
||||
if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
|
||||
{
|
||||
if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) {
|
||||
$langs->load("trips");
|
||||
$listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport');
|
||||
}
|
||||
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
||||
{
|
||||
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) {
|
||||
$langs->load("trips");
|
||||
$listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport');
|
||||
}
|
||||
if (count($listofsearchfields))
|
||||
{
|
||||
if (count($listofsearchfields)) {
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i = 0;
|
||||
foreach ($listofsearchfields as $key => $value)
|
||||
{
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
foreach ($listofsearchfields as $key => $value) {
|
||||
if ($i == 0) {
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
}
|
||||
print '<tr '.$bc[false].'>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
if ($i == 0) {
|
||||
print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
|
@ -135,10 +139,8 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
|
|||
}
|
||||
|
||||
|
||||
if (!empty($conf->holiday->enabled))
|
||||
{
|
||||
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||
{
|
||||
if (!empty($conf->holiday->enabled)) {
|
||||
if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
|
||||
$user_id = $user->id;
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
|
|
@ -149,8 +151,7 @@ if (!empty($conf->holiday->enabled))
|
|||
|
||||
$out = '';
|
||||
$typeleaves = $holiday->getTypes(1, 1);
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$nb_type = $holiday->getCPforUser($user->id, $val['rowid']);
|
||||
$nb_holiday += $nb_type;
|
||||
$out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
|
||||
|
|
@ -161,8 +162,7 @@ if (!empty($conf->holiday->enabled))
|
|||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table></div><br>';
|
||||
} elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||
{
|
||||
} elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) {
|
||||
print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
|
||||
}
|
||||
}
|
||||
|
|
@ -173,22 +173,22 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
|||
|
||||
|
||||
// Latest leave requests
|
||||
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
|
||||
{
|
||||
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) {
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
|
||||
$sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE u.rowid = x.fk_user";
|
||||
$sql .= " AND x.entity = ".$conf->entity;
|
||||
if (empty($user->rights->holiday->readall)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
|
||||
if (empty($user->rights->holiday->readall)) {
|
||||
$sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
|
||||
}
|
||||
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
//if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
|
||||
$sql .= $db->order("x.tms", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$var = false;
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
|
|
@ -208,10 +208,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
|
|||
print '<th>'.$langs->trans("to").'</th>';
|
||||
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
|
||||
print '</tr>';
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num && $i < $max)
|
||||
{
|
||||
if ($num) {
|
||||
while ($i < $num && $i < $max) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$holidaystatic->id = $obj->rowid;
|
||||
|
|
@ -248,28 +246,30 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
|
|||
print '</table>';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Latest expense report
|
||||
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
||||
{
|
||||
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) {
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,";
|
||||
$sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
|
||||
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE u.rowid = x.fk_user_author";
|
||||
$sql .= " AND x.entity = ".$conf->entity;
|
||||
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')';
|
||||
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) {
|
||||
$sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')';
|
||||
}
|
||||
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
//if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
|
||||
$sql .= $db->order("x.tms", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
|
@ -281,14 +281,12 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
|||
print '<th class="right">'.$langs->trans("TotalTTC").'</th>';
|
||||
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
|
||||
print '</tr>';
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$total_ttc = $totalam = $total = 0;
|
||||
|
||||
$expensereportstatic = new ExpenseReport($db);
|
||||
$userstatic = new User($db);
|
||||
while ($i < $num && $i < $max)
|
||||
{
|
||||
while ($i < $num && $i < $max) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$expensereportstatic->id = $obj->rowid;
|
||||
|
|
@ -320,26 +318,32 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
|||
print '</table>';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Last modified job position
|
||||
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
|
||||
{
|
||||
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
|
||||
$sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($socid) $sql .= " AND s.fk_soc = $socid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " AND s.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " ORDER BY rc.tms DESC";
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
|
|
@ -351,10 +355,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
|
|||
print '</th>';
|
||||
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
|
||||
print '</tr>';
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($num) {
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
$staticrecruitmentcandidature->id = $objp->rowid;
|
||||
$staticrecruitmentcandidature->ref = $objp->ref;
|
||||
|
|
|
|||
|
|
@ -87,15 +87,17 @@ class Import
|
|||
$modulesdir = dolGetModulesDirs();
|
||||
|
||||
// Load list of modules
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
foreach ($modulesdir as $dir) {
|
||||
$handle = @opendir(dol_osencode($dir));
|
||||
if (!is_resource($handle)) continue;
|
||||
if (!is_resource($handle)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search module files
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) continue;
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$modulename = $reg[1];
|
||||
|
||||
|
|
@ -103,10 +105,16 @@ class Import
|
|||
$enabled = true;
|
||||
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
|
||||
// Adds condition for propal module
|
||||
if ($part === 'propale') $part = 'propal';
|
||||
if (empty($conf->$part->enabled)) $enabled = false;
|
||||
if ($part === 'propale') {
|
||||
$part = 'propal';
|
||||
}
|
||||
if (empty($conf->$part->enabled)) {
|
||||
$enabled = false;
|
||||
}
|
||||
|
||||
if (empty($enabled)) continue;
|
||||
if (empty($enabled)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Init load class
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
|
|
@ -114,11 +122,11 @@ class Import
|
|||
require_once $file;
|
||||
$module = new $classname($this->db);
|
||||
|
||||
if (isset($module->import_code) && is_array($module->import_code))
|
||||
{
|
||||
foreach ($module->import_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->import_code[$r])) continue;
|
||||
if (isset($module->import_code) && is_array($module->import_code)) {
|
||||
foreach ($module->import_code as $r => $value) {
|
||||
if ($filter && ($filter != $module->import_code[$r])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Test if permissions are ok
|
||||
/*$perm=$module->import_permission[$r][0];
|
||||
|
|
@ -137,10 +145,8 @@ class Import
|
|||
|
||||
// Load lang file
|
||||
$langtoload = $module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach ($langtoload as $key)
|
||||
{
|
||||
if (is_array($langtoload)) {
|
||||
foreach ($langtoload as $key) {
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
|
|
@ -246,9 +252,15 @@ class Import
|
|||
dol_syslog("Import.class.php::create");
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->model_name)) { $this->error = 'ErrorWrongParameters'; return -1; }
|
||||
if (empty($this->datatoimport)) { $this->error = 'ErrorWrongParameters'; return -1; }
|
||||
if (empty($this->hexa)) { $this->error = 'ErrorWrongParameters'; return -1; }
|
||||
if (empty($this->model_name)) {
|
||||
$this->error = 'ErrorWrongParameters'; return -1;
|
||||
}
|
||||
if (empty($this->datatoimport)) {
|
||||
$this->error = 'ErrorWrongParameters'; return -1;
|
||||
}
|
||||
if (empty($this->hexa)) {
|
||||
$this->error = 'ErrorWrongParameters'; return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
|
@ -259,8 +271,7 @@ class Import
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -285,11 +296,9 @@ class Import
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->hexa = $obj->field;
|
||||
$this->model_name = $obj->label;
|
||||
|
|
@ -325,26 +334,24 @@ class Import
|
|||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
/* Not used. This is not a business object. To convert it we must herit from CommonObject
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('IMPORT_DELETE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
*/
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('IMPORT_DELETE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@
|
|||
* \brief Show example of import file
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -58,8 +60,7 @@ $format = GETPOST('format');
|
|||
$langs->load("exports");
|
||||
|
||||
// Check exportkey
|
||||
if (empty($datatoimport))
|
||||
{
|
||||
if (empty($datatoimport)) {
|
||||
$user->getrights();
|
||||
|
||||
llxHeader();
|
||||
|
|
@ -81,23 +82,30 @@ $fieldstarget = $objimport->array_import_fields[0];
|
|||
$valuestarget = $objimport->array_import_examplevalues[0];
|
||||
|
||||
$attachment = true;
|
||||
if (isset($_GET["attachment"])) $attachment = $_GET["attachment"];
|
||||
if (isset($_GET["attachment"])) {
|
||||
$attachment = $_GET["attachment"];
|
||||
}
|
||||
//$attachment = false;
|
||||
$contenttype = dol_mimetype($format);
|
||||
if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"];
|
||||
if (isset($_GET["contenttype"])) {
|
||||
$contenttype = $_GET["contenttype"];
|
||||
}
|
||||
//$contenttype='text/plain';
|
||||
$outputencoding = 'UTF-8';
|
||||
|
||||
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
if ($contenttype) {
|
||||
header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
|
||||
}
|
||||
if ($attachment) {
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
|
||||
// List of targets fields
|
||||
$headerlinefields = array();
|
||||
$contentlinevalues = array();
|
||||
$i = 0;
|
||||
foreach ($fieldstarget as $code=>$label)
|
||||
{
|
||||
foreach ($fieldstarget as $code => $label) {
|
||||
$withoutstar = preg_replace('/\*/', '', $fieldstarget[$code]);
|
||||
$headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ? '*' : '').' ('.$code.')';
|
||||
$contentlinevalues[] = $valuestarget[$code];
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php';
|
|||
// Load translation files required by the page
|
||||
$langs->load("exports");
|
||||
|
||||
if (!$user->socid == 0)
|
||||
accessforbidden();
|
||||
if (!$user->socid == 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$import = new Import($db);
|
||||
$import->load_arrays($user);
|
||||
|
|
@ -49,8 +50,7 @@ print '<br>';
|
|||
|
||||
|
||||
print '<div class="center">';
|
||||
if (count($import->array_import_code))
|
||||
{
|
||||
if (count($import->array_import_code)) {
|
||||
print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import');
|
||||
}
|
||||
print '</div>';
|
||||
|
|
@ -70,8 +70,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php';
|
|||
$model = new ModeleImports();
|
||||
$list = $model->liste_modeles($db);
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
foreach ($list as $key) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
|
||||
$text = $model->getDriverDescForKey($key);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
|||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "intracommreport"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
|
|
@ -46,10 +48,8 @@ $list_DES = array(
|
|||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
foreach ($list_DEB as $constname)
|
||||
{
|
||||
if (!$error) {
|
||||
foreach ($list_DEB as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
|
|
@ -57,8 +57,7 @@ if ($action == 'update') {
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($list_DES as $constname)
|
||||
{
|
||||
foreach ($list_DES as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
|
|
@ -110,8 +109,7 @@ print '<td>'.$langs->trans("Description").'</td>';
|
|||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($list_DEB as $key)
|
||||
{
|
||||
foreach ($list_DEB as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
|
|
@ -175,8 +173,7 @@ print '<td>'.$langs->trans("Description").'</td>';
|
|||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($list_DES as $key)
|
||||
{
|
||||
foreach ($list_DES as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
|
|
|
|||
|
|
@ -24,9 +24,15 @@
|
|||
* \brief File to calculate loan monthly payments
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
|
||||
require '../main.inc.php';
|
||||
require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
|
||||
|
|
|
|||
|
|
@ -28,8 +28,12 @@ require '../main.inc.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||
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/class/html.formaccounting.class.php';
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
}
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
|
||||
|
|
@ -45,7 +49,9 @@ $projectid = GETPOST('projectid', 'int');
|
|||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'loan', $id, '', '');
|
||||
|
||||
$object = new Loan($db);
|
||||
|
|
@ -60,16 +66,15 @@ $error = 0;
|
|||
*/
|
||||
|
||||
$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');
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
// Classify paid
|
||||
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaid($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($loan->error, null, 'errors');
|
||||
|
|
@ -77,12 +82,10 @@ if (empty($reshook))
|
|||
}
|
||||
|
||||
// Delete loan
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) {
|
||||
$object->fetch($id);
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
|
|
@ -92,44 +95,37 @@ if (empty($reshook))
|
|||
}
|
||||
|
||||
// Add loan
|
||||
if ($action == 'add' && $user->rights->loan->write)
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
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'));
|
||||
$rate = GETPOST('rate');
|
||||
|
||||
if (!$capital)
|
||||
{
|
||||
if (!$capital) {
|
||||
$error++; $action = 'create';
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
||||
}
|
||||
if (!$datestart)
|
||||
{
|
||||
if (!$datestart) {
|
||||
$error++; $action = 'create';
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
|
||||
}
|
||||
if (!$dateend)
|
||||
{
|
||||
if (!$dateend) {
|
||||
$error++; $action = 'create';
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
|
||||
}
|
||||
if ($rate == '')
|
||||
{
|
||||
if ($rate == '') {
|
||||
$error++; $action = 'create';
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->label = GETPOST('label');
|
||||
$object->fk_bank = GETPOST('accountid');
|
||||
$object->capital = $capital;
|
||||
$object->fk_bank = GETPOST('accountid');
|
||||
$object->capital = $capital;
|
||||
$object->datestart = $datestart;
|
||||
$object->dateend = $dateend;
|
||||
$object->nbterm = GETPOST('nbterm');
|
||||
$object->dateend = $dateend;
|
||||
$object->nbterm = GETPOST('nbterm');
|
||||
$object->rate = $rate;
|
||||
$object->note_private = GETPOST('note_private', 'restricthtml');
|
||||
$object->note_public = GETPOST('note_public', 'restricthtml');
|
||||
|
|
@ -140,13 +136,24 @@ if (empty($reshook))
|
|||
$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; }
|
||||
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 ($id <= 0) {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'create';
|
||||
|
|
@ -156,21 +163,16 @@ if (empty($reshook))
|
|||
header("Location: list.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Update record
|
||||
elseif ($action == 'update' && $user->rights->loan->write)
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
} elseif ($action == 'update' && $user->rights->loan->write) {
|
||||
// Update record
|
||||
if (!$cancel) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$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 (!$capital)
|
||||
{
|
||||
if (!$capital) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
|
||||
$action = 'edit';
|
||||
} else {
|
||||
|
|
@ -185,15 +187,26 @@ if (empty($reshook))
|
|||
$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; }
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -207,20 +220,20 @@ if (empty($reshook))
|
|||
}
|
||||
|
||||
// Link to a project
|
||||
if ($action == 'classin' && $user->rights->loan->write)
|
||||
{
|
||||
if ($action == 'classin' && $user->rights->loan->write) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setProject($projectid);
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setlabel' && $user->rights->loan->write)
|
||||
{
|
||||
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');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +244,9 @@ if (empty($reshook))
|
|||
|
||||
$form = new Form($db);
|
||||
$formproject = new FormProjets($db);
|
||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
$title = $langs->trans("Loan").' - '.$langs->trans("Card");
|
||||
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
||||
|
|
@ -239,8 +254,7 @@ llxHeader("", $title, $help_url);
|
|||
|
||||
|
||||
// Create mode
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
|
|
@ -260,8 +274,7 @@ if ($action == 'create')
|
|||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth300" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'" autofocus="autofocus"></td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
||||
$form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant
|
||||
print '</td></tr>';
|
||||
|
|
@ -296,8 +309,7 @@ if ($action == 'create')
|
|||
print '<tr><td>'.$langs->trans("Insurance").'</td><td><input name="insurance_amount" size="10" value="'.dol_escape_htmltag(GETPOST("insurance_amount")).'" placeholder="'.$langs->trans('Amount').'"></td></tr>';
|
||||
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
|
||||
// Projet associe
|
||||
|
|
@ -329,8 +341,7 @@ if ($action == 'create')
|
|||
print '</td></tr>';
|
||||
|
||||
// Accountancy
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
// Accountancy_account_capital
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
||||
print '<td>';
|
||||
|
|
@ -379,32 +390,27 @@ if ($action == 'create')
|
|||
}
|
||||
|
||||
// View
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$object = new Loan($db);
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$head = loan_prepare_head($object);
|
||||
|
||||
$totalpaid = $object->getSumPayment();
|
||||
|
||||
// Confirm for loan
|
||||
if ($action == 'paid')
|
||||
{
|
||||
if ($action == 'paid') {
|
||||
$text = $langs->trans('ConfirmPayLoan');
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayLoan'), $text, "confirm_paid", '', '', 2);
|
||||
}
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$text = $langs->trans('ConfirmDeleteLoan');
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteLoan'), $text, 'confirm_delete', '', '', 2);
|
||||
}
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
|
@ -422,14 +428,13 @@ if ($id > 0)
|
|||
$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);
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->loadLangs(array("projects"));
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->loan->write)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
if ($user->rights->loan->write) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" 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.'">';
|
||||
|
|
@ -466,8 +471,7 @@ if ($id > 0)
|
|||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Capital
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<tr><td class="fieldrequired titlefield">'.$langs->trans("LoanCapital").'</td><td>';
|
||||
print '<input name="capital" size="10" value="'.$object->capital.'"></td></tr>';
|
||||
print '</td></tr>';
|
||||
|
|
@ -476,8 +480,7 @@ if ($id > 0)
|
|||
}
|
||||
|
||||
// Insurance
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Insurance").'</td><td>';
|
||||
print '<input name="insurance_amount" size="10" value="'.$object->insurance_amount.'"></td></tr>';
|
||||
print '</td></tr>';
|
||||
|
|
@ -488,8 +491,7 @@ if ($id > 0)
|
|||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart")."</td>";
|
||||
print "<td>";
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print $form->selectDate($object->datestart, 'start', 0, 0, 0, 'update', 1, 0);
|
||||
} else {
|
||||
print dol_print_date($object->datestart, "day");
|
||||
|
|
@ -499,8 +501,7 @@ if ($id > 0)
|
|||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd")."</td>";
|
||||
print "<td>";
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print $form->selectDate($object->dateend, 'end', 0, 0, 0, 'update', 1, 0);
|
||||
} else {
|
||||
print dol_print_date($object->dateend, "day");
|
||||
|
|
@ -510,8 +511,7 @@ if ($id > 0)
|
|||
// Nbterms
|
||||
print '<tr><td>'.$langs->trans("Nbterms").'</td>';
|
||||
print '<td>';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input name="nbterm" size="4" value="'.$object->nbterm.'">';
|
||||
} else {
|
||||
print $object->nbterm;
|
||||
|
|
@ -521,8 +521,7 @@ if ($id > 0)
|
|||
// Rate
|
||||
print '<tr><td>'.$langs->trans("Rate").'</td>';
|
||||
print '<td>';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input name="rate" size="4" value="'.$object->rate.'">%';
|
||||
} else {
|
||||
print price($object->rate).'%';
|
||||
|
|
@ -531,14 +530,12 @@ if ($id > 0)
|
|||
|
||||
// Accountancy account capital
|
||||
print '<tr>';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<td class="nowrap fieldrequired">';
|
||||
print $langs->trans("LoanAccountancyCapitalCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input name="accountancy_account_capital" size="16" value="'.$object->account_capital.'">';
|
||||
|
|
@ -549,8 +546,7 @@ if ($id > 0)
|
|||
print $langs->trans("LoanAccountancyCapitalCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $object->account_capital, 1);
|
||||
|
||||
|
|
@ -565,14 +561,12 @@ if ($id > 0)
|
|||
|
||||
// Accountancy account insurance
|
||||
print '<tr>';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<td class="nowrap fieldrequired">';
|
||||
print $langs->trans("LoanAccountancyInsuranceCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input name="accountancy_account_insurance" size="16" value="'.$object->account_insurance.'">';
|
||||
|
|
@ -583,8 +577,7 @@ if ($id > 0)
|
|||
print $langs->trans("LoanAccountancyInsuranceCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $object->account_insurance, 1);
|
||||
|
||||
|
|
@ -599,14 +592,12 @@ if ($id > 0)
|
|||
|
||||
// Accountancy account interest
|
||||
print '<tr>';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<td class="nowrap fieldrequired">';
|
||||
print $langs->trans("LoanAccountancyInterestCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input name="accountancy_account_interest" size="16" value="'.$object->account_interest.'">';
|
||||
|
|
@ -617,8 +608,7 @@ if ($id > 0)
|
|||
print $langs->trans("LoanAccountancyInterestCode");
|
||||
print '</td><td>';
|
||||
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $object->account_interest, 1);
|
||||
|
||||
|
|
@ -653,8 +643,7 @@ if ($id > 0)
|
|||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$total_insurance = 0;
|
||||
|
|
@ -672,8 +661,7 @@ if ($id > 0)
|
|||
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -690,8 +678,7 @@ if ($id > 0)
|
|||
|
||||
$totalpaid = $total_capital;
|
||||
|
||||
if ($object->paid == 0 || $object->paid == 2)
|
||||
{
|
||||
if ($object->paid == 0 || $object->paid == 2) {
|
||||
print '<tr><td colspan="5" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td colspan="5" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
|
|
@ -718,8 +705,7 @@ if ($id > 0)
|
|||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
|
|
@ -732,34 +718,28 @@ if ($id > 0)
|
|||
/*
|
||||
* Buttons actions
|
||||
*/
|
||||
if ($action != 'edit')
|
||||
{
|
||||
if ($action != 'edit') {
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Edit
|
||||
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write)
|
||||
{
|
||||
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>';
|
||||
}
|
||||
|
||||
// Emit payment
|
||||
if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
||||
{
|
||||
if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a></div>';
|
||||
}
|
||||
|
||||
// Classify 'paid'
|
||||
if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write)
|
||||
{
|
||||
if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid").'</a></div>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete)
|
||||
{
|
||||
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,10 +135,8 @@ class Loan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
|
@ -188,36 +186,52 @@ class Loan extends CommonObject
|
|||
|
||||
// clean parameters
|
||||
$newcapital = price2num($this->capital, 'MT');
|
||||
if (empty($this->insurance_amount)) $this->insurance_amount = 0;
|
||||
if (empty($this->insurance_amount)) {
|
||||
$this->insurance_amount = 0;
|
||||
}
|
||||
$newinsuranceamount = price2num($this->insurance_amount, 'MT');
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital);
|
||||
if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance);
|
||||
if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project;
|
||||
if (isset($this->note_private)) {
|
||||
$this->note_private = trim($this->note_private);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note_public = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->account_capital)) {
|
||||
$this->account_capital = trim($this->account_capital);
|
||||
}
|
||||
if (isset($this->account_insurance)) {
|
||||
$this->account_insurance = trim($this->account_insurance);
|
||||
}
|
||||
if (isset($this->account_interest)) {
|
||||
$this->account_interest = trim($this->account_interest);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
if (isset($this->fk_project)) {
|
||||
$this->fk_project = (int) $this->fk_project;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend))
|
||||
{
|
||||
if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) {
|
||||
$this->error = "ErrorBadParameter";
|
||||
return -2;
|
||||
}
|
||||
if (($conf->accounting->enabled) && empty($this->account_capital))
|
||||
{
|
||||
if (($conf->accounting->enabled) && empty($this->account_capital)) {
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
|
||||
return -2;
|
||||
}
|
||||
if (($conf->accounting->enabled) && empty($this->account_insurance))
|
||||
{
|
||||
if (($conf->accounting->enabled) && empty($this->account_insurance)) {
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
|
||||
return -2;
|
||||
}
|
||||
if (($conf->accounting->enabled) && empty($this->account_interest))
|
||||
{
|
||||
if (($conf->accounting->enabled) && empty($this->account_interest)) {
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -248,8 +262,7 @@ class Loan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
|
||||
|
||||
//dol_syslog("Loans::create this->id=".$this->id);
|
||||
|
|
@ -281,47 +294,39 @@ class Loan extends CommonObject
|
|||
$lines_url = $account->get_url('', $this->id, 'loan');
|
||||
|
||||
// Delete bank urls
|
||||
foreach ($lines_url as $line_url)
|
||||
{
|
||||
if (!$error)
|
||||
{
|
||||
foreach ($lines_url as $line_url) {
|
||||
if (!$error) {
|
||||
$accountline = new AccountLine($this->db);
|
||||
$accountline->fetch($line_url['fk_bank']);
|
||||
$result = $accountline->delete_urls($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete payments
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -341,8 +346,7 @@ class Loan extends CommonObject
|
|||
{
|
||||
$this->db->begin();
|
||||
|
||||
if (!is_numeric($this->nbterm))
|
||||
{
|
||||
if (!is_numeric($this->nbterm)) {
|
||||
$this->error = 'BadValueForParameterForNbTerm';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -364,8 +368,7 @@ class Loan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -512,22 +515,29 @@ class Loan extends CommonObject
|
|||
$langs->loadLangs(array("customers", "bills"));
|
||||
|
||||
unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid');
|
||||
$this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid');
|
||||
$this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted");
|
||||
if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
if ($status == 0 && $alreadypaid > 0) {
|
||||
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
}
|
||||
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid');
|
||||
$this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled');
|
||||
$this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted");
|
||||
if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
if ($status == 0 && $alreadypaid > 0) {
|
||||
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
|
||||
}
|
||||
}
|
||||
|
||||
$statusType = 'status1';
|
||||
if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) $statusType = 'status3';
|
||||
if ($status == 1) $statusType = 'status6';
|
||||
if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
|
||||
$statusType = 'status3';
|
||||
}
|
||||
if ($status == 1) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
|
@ -560,33 +570,40 @@ class Loan extends CommonObject
|
|||
|
||||
$url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id;
|
||||
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowMyObject");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
|
|
@ -638,12 +655,13 @@ class Loan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$amount = 0;
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $amount = $obj->amount ? $obj->amount : 0;
|
||||
if ($obj) {
|
||||
$amount = $obj->amount ? $obj->amount : 0;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
return $amount;
|
||||
|
|
@ -668,26 +686,24 @@ class Loan extends CommonObject
|
|||
dol_syslog(get_class($this).'::info', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_modif)
|
||||
{
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_modif);
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
if (empty($obj->fk_user_modif)) $obj->tms = "";
|
||||
if (empty($obj->fk_user_modif)) {
|
||||
$obj->tms = "";
|
||||
}
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
|
||||
$this->db->free($result);
|
||||
|
|
|
|||
|
|
@ -129,21 +129,36 @@ class LoanSchedule extends CommonObject
|
|||
$now = dol_now();
|
||||
|
||||
// Validate parameters
|
||||
if (!$this->datep)
|
||||
{
|
||||
if (!$this->datep) {
|
||||
$this->error = 'ErrorBadValueForParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
|
||||
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0);
|
||||
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0);
|
||||
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_loan)) {
|
||||
$this->fk_loan = (int) $this->fk_loan;
|
||||
}
|
||||
if (isset($this->amount_capital)) {
|
||||
$this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0);
|
||||
}
|
||||
if (isset($this->amount_insurance)) {
|
||||
$this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0);
|
||||
}
|
||||
if (isset($this->amount_interest)) {
|
||||
$this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0);
|
||||
}
|
||||
if (isset($this->fk_typepayment)) {
|
||||
$this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
|
||||
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
|
||||
$totalamount = price2num($totalamount);
|
||||
|
|
@ -157,8 +172,7 @@ class LoanSchedule extends CommonObject
|
|||
|
||||
$this->db->begin();
|
||||
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
if ($totalamount != 0) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
|
||||
$sql .= " fk_typepayment, fk_user_creat, fk_bank)";
|
||||
$sql .= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',";
|
||||
|
|
@ -172,8 +186,7 @@ class LoanSchedule extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
|
|
@ -181,8 +194,7 @@ class LoanSchedule extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if ($totalamount != 0 && !$error)
|
||||
{
|
||||
if ($totalamount != 0 && !$error) {
|
||||
$this->amount_capital = $totalamount;
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
|
|
@ -280,14 +292,30 @@ class LoanSchedule extends CommonObject
|
|||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital);
|
||||
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance);
|
||||
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank);
|
||||
if (isset($this->fk_payment_loan)) $this->fk_payment_loan = (int) $this->fk_payment_loan;
|
||||
if (isset($this->amount_capital)) {
|
||||
$this->amount_capital = trim($this->amount_capital);
|
||||
}
|
||||
if (isset($this->amount_insurance)) {
|
||||
$this->amount_insurance = trim($this->amount_insurance);
|
||||
}
|
||||
if (isset($this->amount_interest)) {
|
||||
$this->amount_interest = trim($this->amount_interest);
|
||||
}
|
||||
if (isset($this->num_payment)) {
|
||||
$this->num_payment = trim($this->num_payment);
|
||||
}
|
||||
if (isset($this->note_private)) {
|
||||
$this->note_private = trim($this->note_private);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note_public = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = trim($this->fk_bank);
|
||||
}
|
||||
if (isset($this->fk_payment_loan)) {
|
||||
$this->fk_payment_loan = (int) $this->fk_payment_loan;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
|
@ -317,11 +345,12 @@ class LoanSchedule extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1 * $error;
|
||||
} else {
|
||||
|
|
@ -351,14 +380,14 @@ class LoanSchedule extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -423,10 +452,8 @@ class LoanSchedule extends CommonObject
|
|||
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$line = new LoanSchedule($this->db);
|
||||
$line->id = $obj->rowid;
|
||||
$line->ref = $obj->rowid;
|
||||
|
|
@ -537,14 +564,15 @@ class LoanSchedule extends CommonObject
|
|||
$sql = "SELECT p.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p ";
|
||||
$sql .= " WHERE p.fk_loan = ".$loanid;
|
||||
if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; }
|
||||
if (!empty($datemax)) {
|
||||
$sql .= " AND p.datep > '".$this->db->idate($datemax)."'";
|
||||
}
|
||||
$sql .= " AND p.datep <= '".$this->db->idate(dol_now())."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$result[] = $obj->rowid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,36 +126,58 @@ class PaymentLoan extends CommonObject
|
|||
$now = dol_now();
|
||||
|
||||
// Validate parameters
|
||||
if (!$this->datep)
|
||||
{
|
||||
if (!$this->datep) {
|
||||
$this->error = 'ErrorBadValueForParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
|
||||
if (isset($this->amount_capital)) $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0);
|
||||
if (isset($this->amount_insurance)) $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0);
|
||||
if (isset($this->amount_interest)) $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment;
|
||||
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_loan)) {
|
||||
$this->fk_loan = (int) $this->fk_loan;
|
||||
}
|
||||
if (isset($this->amount_capital)) {
|
||||
$this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0);
|
||||
}
|
||||
if (isset($this->amount_insurance)) {
|
||||
$this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0);
|
||||
}
|
||||
if (isset($this->amount_interest)) {
|
||||
$this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0);
|
||||
}
|
||||
if (isset($this->fk_typepayment)) {
|
||||
$this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
}
|
||||
if (isset($this->num_payment)) {
|
||||
$this->num_payment = (int) $this->num_payment;
|
||||
}
|
||||
if (isset($this->note_private)) {
|
||||
$this->note_private = trim($this->note_private);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note_public = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
|
||||
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
|
||||
$totalamount = price2num($totalamount);
|
||||
|
||||
// Check parameters
|
||||
if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
|
||||
if ($totalamount == 0) {
|
||||
return -1; // Negative amounts are accepted for reject prelevement but not null
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
if ($totalamount != 0) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
|
||||
$sql .= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)";
|
||||
$sql .= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
|
||||
|
|
@ -168,8 +190,7 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
|
|
@ -177,8 +198,7 @@ class PaymentLoan extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if ($totalamount != 0 && !$error)
|
||||
{
|
||||
if ($totalamount != 0 && !$error) {
|
||||
$this->amount_capital = $totalamount;
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
|
|
@ -223,10 +243,8 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
|
@ -276,17 +294,39 @@ class PaymentLoan extends CommonObject
|
|||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
|
||||
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital);
|
||||
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance);
|
||||
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment;
|
||||
if (isset($this->note_private)) $this->note = trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_loan)) {
|
||||
$this->fk_loan = (int) $this->fk_loan;
|
||||
}
|
||||
if (isset($this->amount_capital)) {
|
||||
$this->amount_capital = trim($this->amount_capital);
|
||||
}
|
||||
if (isset($this->amount_insurance)) {
|
||||
$this->amount_insurance = trim($this->amount_insurance);
|
||||
}
|
||||
if (isset($this->amount_interest)) {
|
||||
$this->amount_interest = trim($this->amount_interest);
|
||||
}
|
||||
if (isset($this->fk_typepayment)) {
|
||||
$this->fk_typepayment = (int) $this->fk_typepayment;
|
||||
}
|
||||
if (isset($this->num_payment)) {
|
||||
$this->num_payment = (int) $this->num_payment;
|
||||
}
|
||||
if (isset($this->note_private)) {
|
||||
$this->note = trim($this->note_private);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
|
||||
|
|
@ -314,13 +354,13 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -347,35 +387,35 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
||||
$sql .= " WHERE type='payment_loan' AND url_id=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Set loan unpaid if loan has no other payment
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||
$loan = new Loan($this->db);
|
||||
$loan->fetch($this->fk_loan);
|
||||
$sum_payment = $loan->getSumPayment();
|
||||
if ($sum_payment == 0)
|
||||
{
|
||||
if ($sum_payment == 0) {
|
||||
dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG);
|
||||
if ($loan->setUnpaid($user) < 1) {
|
||||
$error++;
|
||||
|
|
@ -401,10 +441,8 @@ class PaymentLoan extends CommonObject
|
|||
//}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -461,15 +499,16 @@ class PaymentLoan extends CommonObject
|
|||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$acc->fetch($accountid);
|
||||
|
||||
$total = $this->amount_capital;
|
||||
if ($mode == 'payment_loan') $total = -$total;
|
||||
if ($mode == 'payment_loan') {
|
||||
$total = -$total;
|
||||
}
|
||||
|
||||
// Insert payment into llx_bank
|
||||
$bank_line_id = $acc->addline(
|
||||
|
|
@ -486,23 +525,21 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
// Update fk_bank into llx_paiement.
|
||||
// We know the payment who generated the account write
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
if ($bank_line_id > 0) {
|
||||
$result = $this->update_fk_bank($bank_line_id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Add link 'payment_loan' in bank_url between payment and bank transaction
|
||||
$url = '';
|
||||
if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id=';
|
||||
if ($url)
|
||||
{
|
||||
if ($mode == 'payment_loan') {
|
||||
$url = DOL_URL_ROOT.'/loan/payment/card.php?id=';
|
||||
}
|
||||
if ($url) {
|
||||
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
|
@ -510,10 +547,11 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
|
||||
// Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
|
||||
if ($mode == 'payment_loan')
|
||||
{
|
||||
if ($mode == 'payment_loan') {
|
||||
$result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan');
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = $acc->error;
|
||||
|
|
@ -523,28 +561,23 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
|
||||
// Set loan payment started if no set
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||
$loan = new Loan($this->db);
|
||||
$loan->fetch($fk_loan);
|
||||
if ($loan->paid == $loan::STATUS_UNPAID)
|
||||
{
|
||||
if ($loan->paid == $loan::STATUS_UNPAID) {
|
||||
dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG);
|
||||
if ($loan->setStarted($user) < 1)
|
||||
{
|
||||
if ($loan->setStarted($user) < 1) {
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -565,8 +598,7 @@ class PaymentLoan extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$this->fk_bank = $id_bank;
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -589,27 +621,39 @@ class PaymentLoan extends CommonObject
|
|||
{
|
||||
global $langs, $conf;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$label = '<u>'.$langs->trans("Loan").'</u>';
|
||||
if (!empty($this->id)) {
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
|
||||
}
|
||||
if ($moretitle) $label .= ' - '.$moretitle;
|
||||
if ($moretitle) {
|
||||
$label .= ' - '.$moretitle;
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id;
|
||||
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ $action = GETPOST('action', 'aZ09');
|
|||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'loan', $id, '', '');
|
||||
|
||||
// Get parameters
|
||||
|
|
@ -54,11 +56,17 @@ if (empty($page) || $page == -1) {
|
|||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
$object = new Loan($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
$upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
$modulepart = 'loan';
|
||||
|
|
@ -81,8 +89,7 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Documents");
|
|||
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
||||
llxHeader("", $title, $help_url);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$totalpaid = $object->getSumPayment();
|
||||
|
||||
$head = loan_prepare_head($object);
|
||||
|
|
@ -138,8 +145,7 @@ if ($object->id)
|
|||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file)
|
||||
{
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ $action = GETPOST('action', 'aZ09');
|
|||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'loan', $id, '', '');
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,14 +32,18 @@ $langs->loadLangs(array("loan", "compta", "banks", "bills"));
|
|||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'loan', '', '', '');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
|
@ -48,8 +52,12 @@ $pagenext = $page + 1;
|
|||
$loan_static = new Loan($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
if (!$sortfield) $sortfield = "l.rowid";
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "l.rowid";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
|
||||
$search_ref = GETPOST('search_ref', 'int');
|
||||
$search_label = GETPOST('search_label', 'alpha');
|
||||
|
|
@ -63,18 +71,22 @@ $optioncss = GETPOST('optioncss', 'alpha');
|
|||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$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');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_ref = "";
|
||||
$search_label = "";
|
||||
$search_amount = "";
|
||||
|
|
@ -97,35 +109,39 @@ $sql .= " SUM(pl.amount_capital) as alreadypaid";
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl";
|
||||
$sql .= " ON l.rowid = pl.fk_loan";
|
||||
$sql .= " WHERE l.entity = ".$conf->entity;
|
||||
if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1);
|
||||
if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref);
|
||||
if ($search_label) $sql .= natural_search("l.label", $search_label);
|
||||
if ($search_amount) {
|
||||
$sql .= natural_search("l.capital", $search_amount, 1);
|
||||
}
|
||||
if ($search_ref) {
|
||||
$sql .= " AND l.rowid = ".$db->escape($search_ref);
|
||||
}
|
||||
if ($search_label) {
|
||||
$sql .= natural_search("l.label", $search_label);
|
||||
}
|
||||
$sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
|
||||
{
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
|
||||
$num = $nbtotalofrecords;
|
||||
} else {
|
||||
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
|
||||
if ($limit) {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
|
@ -138,24 +154,39 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
|
|||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
|
||||
if ($search_label) $param .= "&search_label=".urlencode($search_label);
|
||||
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($search_ref) {
|
||||
$param .= "&search_ref=".urlencode($search_ref);
|
||||
}
|
||||
if ($search_label) {
|
||||
$param .= "&search_label=".urlencode($search_label);
|
||||
}
|
||||
if ($search_amount) {
|
||||
$param .= "&search_amount=".urlencode($search_amount);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/loan/card.php?action=create';
|
||||
if (!empty($socid)) $url .= '&socid='.$socid;
|
||||
if (!empty($socid)) {
|
||||
$url .= '&socid='.$socid;
|
||||
}
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
|
|
@ -201,10 +232,11 @@ if ($resql)
|
|||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < ($limit ? min($num, $limit) : $num))
|
||||
{
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) {
|
||||
break; // Should not happen
|
||||
}
|
||||
|
||||
$loan_static->id = $obj->rowid;
|
||||
$loan_static->ref = $obj->rowid;
|
||||
|
|
@ -240,8 +272,7 @@ if ($resql)
|
|||
}
|
||||
|
||||
// If no record found
|
||||
if ($num == 0)
|
||||
{
|
||||
if ($num == 0) {
|
||||
$colspan = 7;
|
||||
//foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ $id = GETPOST('id', 'int');
|
|||
$result = restrictedArea($user, 'loan', $id, '&loan');
|
||||
|
||||
$object = new Loan($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
|
|
@ -66,11 +68,10 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Notes");
|
|||
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
||||
llxHeader("", $title, $help_url);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
* Affichage onglets
|
||||
*/
|
||||
$totalpaid = $object->getSumPayment();
|
||||
|
||||
$head = loan_prepare_head($object);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@
|
|||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
|
||||
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("bills", "banks", "companies", "loan"));
|
||||
|
|
@ -33,15 +35,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "loan"));
|
|||
$id = GETPOST("id", 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
// TODO ajouter regle pour restreindre acces paiement
|
||||
//$result = restrictedArea($user, 'facture', $id,'');
|
||||
|
||||
$payment = new PaymentLoan($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$result = $payment->fetch($id);
|
||||
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
|
||||
if (!$result) {
|
||||
dol_print_error($db, 'Failed to get payment id '.$id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -50,8 +55,7 @@ if ($id > 0)
|
|||
*/
|
||||
|
||||
// Delete payment
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete)
|
||||
{
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) {
|
||||
$db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank;
|
||||
|
|
@ -60,8 +64,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del
|
|||
$fk_loan = $payment->fk_loan;
|
||||
|
||||
$result = $payment->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan);
|
||||
exit;
|
||||
|
|
@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), -1, 'p
|
|||
/*
|
||||
* Confirm deletion of the payment
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +129,8 @@ print '<tr><td>'.$langs->trans('NotePrivate').'</td><td>'.nl2br($payment->note_p
|
|||
print '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.nl2br($payment->note_public).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if ($payment->bank_account)
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
if ($payment->bank_account) {
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($payment->bank_line);
|
||||
|
||||
|
|
@ -161,8 +161,7 @@ $sql .= ' AND pl.rowid = '.$payment->id;
|
|||
|
||||
dol_syslog("loan/payment/card.php", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
|
|
@ -176,10 +175,8 @@ if ($resql)
|
|||
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($num > 0) {
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -199,8 +196,7 @@ if ($resql)
|
|||
|
||||
print '<td class="right">'.price($amount_payed).'</td>';
|
||||
print "</tr>\n";
|
||||
if ($objp->paid == 1) // If at least one invoice is paid, disable delete
|
||||
{
|
||||
if ($objp->paid == 1) { // If at least one invoice is paid, disable delete
|
||||
$disable_delete = 1;
|
||||
}
|
||||
$total = $total + $objp->amount_capital;
|
||||
|
|
@ -224,10 +220,8 @@ print '</div>';
|
|||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (empty($action) && !empty($user->rights->loan->delete))
|
||||
{
|
||||
if (!$disable_delete)
|
||||
{
|
||||
if (empty($action) && !empty($user->rights->loan->delete)) {
|
||||
if (!$disable_delete) {
|
||||
print '<a class="butActionDelete" href="card.php?id='.$id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
|
|
|
|||
|
|
@ -39,10 +39,14 @@ $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'in
|
|||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if ($user->socid > 0)
|
||||
if ($user->socid > 0) {
|
||||
$socid = $user->socid;
|
||||
elseif (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int');
|
||||
if (empty($user->rights->loan->write)) accessforbidden();
|
||||
} elseif (GETPOSTISSET('socid')) {
|
||||
$socid = GETPOST('socid', 'int');
|
||||
}
|
||||
if (empty($user->rights->loan->write)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$loan = new Loan($db);
|
||||
$loan->fetch($chid);
|
||||
|
|
@ -51,35 +55,31 @@ $echance = 0;
|
|||
$ls = new LoanSchedule($db);
|
||||
// grab all loanschedule
|
||||
$res = $ls->fetchAll($chid);
|
||||
if ($res > 0)
|
||||
{
|
||||
foreach ($ls->lines as $l)
|
||||
{
|
||||
if ($res > 0) {
|
||||
foreach ($ls->lines as $l) {
|
||||
$echance++; // Count term pos
|
||||
// last unpaid term
|
||||
if (empty($l->fk_bank))
|
||||
{
|
||||
if (empty($l->fk_bank)) {
|
||||
$line_id = $l->id;
|
||||
break;
|
||||
}
|
||||
// If line_id provided, only count temp pos
|
||||
elseif ($line_id == $l->id)
|
||||
{
|
||||
} elseif ($line_id == $l->id) {
|
||||
// If line_id provided, only count temp pos
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set current line with last unpaid line (only if shedule is used)
|
||||
if (!empty($line_id))
|
||||
{
|
||||
if (!empty($line_id)) {
|
||||
$line = new LoanSchedule($db);
|
||||
$res = $line->fetch($line_id);
|
||||
if ($res > 0) {
|
||||
$amount_capital = price($line->amount_capital);
|
||||
$amount_insurance = price($line->amount_insurance);
|
||||
$amount_interest = price($line->amount_interest);
|
||||
if (empty($datepaid)) $ts_temppaid = $line->datep;
|
||||
if (empty($datepaid)) {
|
||||
$ts_temppaid = $line->datep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,66 +88,59 @@ if (!empty($line_id))
|
|||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add_payment')
|
||||
{
|
||||
if ($action == 'add_payment') {
|
||||
$error = 0;
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($cancel) {
|
||||
$loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid;
|
||||
header("Location: ".$loc);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!GETPOST('paymenttype', 'int') > 0)
|
||||
{
|
||||
if (!GETPOST('paymenttype', 'int') > 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($datepaid == '')
|
||||
{
|
||||
if ($datepaid == '') {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0)
|
||||
{
|
||||
if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$paymentid = 0;
|
||||
|
||||
$pay_amount_capital = price2num(GETPOST('amount_capital'));
|
||||
$pay_amount_insurance = price2num(GETPOST('amount_insurance'));
|
||||
// User can't set interest him self if schedule is set (else value in schedule can be incoherent)
|
||||
if (!empty($line)) $pay_amount_interest = $line->amount_interest;
|
||||
else $pay_amount_interest = price2num(GETPOST('amount_interest'));
|
||||
if (!empty($line)) {
|
||||
$pay_amount_interest = $line->amount_interest;
|
||||
} else {
|
||||
$pay_amount_interest = price2num(GETPOST('amount_interest'));
|
||||
}
|
||||
$remaindertopay = price2num(GETPOST('remaindertopay'));
|
||||
$amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest;
|
||||
|
||||
// This term is allready paid
|
||||
if (!empty($line) && !empty($line->fk_bank))
|
||||
{
|
||||
if (!empty($line) && !empty($line->fk_bank)) {
|
||||
setEventMessages($langs->trans('TermPaidAllreadyPaid'), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($remaindertopay))
|
||||
{
|
||||
if (empty($remaindertopay)) {
|
||||
setEventMessages('Empty sumpaid', null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($amount == 0)
|
||||
{
|
||||
if ($amount == 0) {
|
||||
setEventMessages($langs->trans('ErrorNoPaymentDefined'), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
// Create a line of payments
|
||||
|
|
@ -164,38 +157,30 @@ if ($action == 'add_payment')
|
|||
$payment->note_private = GETPOST('note_private', 'restricthtml');
|
||||
$payment->note_public = GETPOST('note_public', 'restricthtml');
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
if ($paymentid < 0) {
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', $payment->fk_bank, '', '');
|
||||
if (!$result > 0)
|
||||
{
|
||||
if (!$result > 0) {
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Update loan schedule with payment value
|
||||
if (!$error && !empty($line))
|
||||
{
|
||||
if (!$error && !empty($line)) {
|
||||
// If payment values are modified, recalculate schedule
|
||||
if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest))
|
||||
{
|
||||
if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) {
|
||||
$arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm);
|
||||
foreach ($arr_term as $k=>$v)
|
||||
{
|
||||
foreach ($arr_term as $k => $v) {
|
||||
// Update fk_bank for current line
|
||||
if ($k == $echance)
|
||||
{
|
||||
if ($k == $echance) {
|
||||
$ls->lines[$k - 1]->fk_bank = $payment->fk_bank;
|
||||
$ls->lines[$k - 1]->fk_payment_loan = $payment->id;
|
||||
}
|
||||
|
|
@ -204,29 +189,25 @@ if ($action == 'add_payment')
|
|||
$ls->lines[$k - 1]->tms = dol_now();
|
||||
$ls->lines[$k - 1]->fk_user_modif = $user->id;
|
||||
$result = $ls->lines[$k - 1]->update($user, 0);
|
||||
if ($result < 1)
|
||||
{
|
||||
if ($result < 1) {
|
||||
setEventMessages(null, $ls->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Only add fk_bank bank to schedule line (mark as paid)
|
||||
} else // Only add fk_bank bank to schedule line (mark as paid)
|
||||
{
|
||||
$line->fk_bank = $payment->fk_bank;
|
||||
$line->fk_payment_loan = $payment->id;
|
||||
$result = $line->update($user, 0);
|
||||
if ($result < 1)
|
||||
{
|
||||
if ($result < 1) {
|
||||
setEventMessages(null, $line->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
$loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid;
|
||||
header('Location: '.$loc);
|
||||
|
|
@ -251,8 +232,7 @@ $form = new Form($db);
|
|||
|
||||
|
||||
// Form to create loan's payment
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
$total = $loan->capital;
|
||||
|
||||
print load_fiche_titre($langs->trans("DoPayment"));
|
||||
|
|
@ -261,8 +241,7 @@ if ($action == 'create')
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_loan";
|
||||
$sql .= " WHERE fk_loan = ".$chid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$sumpaid = $obj->total;
|
||||
$db->free();
|
||||
|
|
@ -282,10 +261,10 @@ if ($action == 'create')
|
|||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
if ($echance > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n";
|
||||
}
|
||||
if ($echance > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n";
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="2">'.dol_print_date($loan->datestart, 'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$loan->label."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($loan->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
|
@ -300,108 +279,106 @@ if ($action == 'create')
|
|||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
if (empty($datepaid))
|
||||
if (empty($ts_temppaid)) $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now();
|
||||
else $datepayment = $ts_temppaid;
|
||||
else $datepayment = $datepaid;
|
||||
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
if (empty($datepaid)) {
|
||||
if (empty($ts_temppaid)) {
|
||||
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now();
|
||||
} else {
|
||||
$datepayment = $ts_temppaid;
|
||||
}
|
||||
} else {
|
||||
$datepayment = $datepaid;
|
||||
}
|
||||
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
|
||||
$form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype");
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
|
||||
$form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype");
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n";
|
||||
print "</tr>";
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n";
|
||||
print "</tr>";
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="left">'.$langs->trans("DateDue").'</td>';
|
||||
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
|
||||
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
|
||||
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
||||
print "</tr>\n";
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="left">'.$langs->trans("DateDue").'</td>';
|
||||
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
|
||||
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
|
||||
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if ($loan->datestart > 0)
|
||||
{
|
||||
if ($loan->datestart > 0) {
|
||||
print '<td class="left" valign="center">'.dol_print_date($loan->datestart, 'day').'</td>';
|
||||
} else {
|
||||
print '<td class="center" valign="center"><b>!!!</b></td>';
|
||||
}
|
||||
|
||||
print '<td class="right" valign="center">'.price($loan->capital)."</td>";
|
||||
print '<td class="right" valign="center">'.price($loan->capital)."</td>";
|
||||
|
||||
print '<td class="right" valign="center">'.price($sumpaid)."</td>";
|
||||
print '<td class="right" valign="center">'.price($sumpaid)."</td>";
|
||||
|
||||
print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>";
|
||||
print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>";
|
||||
|
||||
print '<td class="right">';
|
||||
if ($sumpaid < $loan->capital)
|
||||
{
|
||||
print '<td class="right">';
|
||||
if ($sumpaid < $loan->capital) {
|
||||
print $langs->trans("LoanCapital").': <input type="text" size="8" name="amount_capital" value="'.(GETPOSTISSET('amount_capital') ?GETPOST('amount_capital') : $amount_capital).'">';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print '-';
|
||||
}
|
||||
print '<br>';
|
||||
if ($sumpaid < $loan->capital)
|
||||
{
|
||||
print '<br>';
|
||||
if ($sumpaid < $loan->capital) {
|
||||
print $langs->trans("Insurance").': <input type="text" size="8" name="amount_insurance" value="'.(GETPOSTISSET('amount_insurance') ?GETPOST('amount_insurance') : $amount_insurance).'">';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print '-';
|
||||
}
|
||||
print '<br>';
|
||||
if ($sumpaid < $loan->capital)
|
||||
{
|
||||
print '<br>';
|
||||
if ($sumpaid < $loan->capital) {
|
||||
print $langs->trans("Interest").': <input type="text" size="8" name="amount_interest" value="'.(GETPOSTISSET('amount_interest') ?GETPOST('amount_interest') : $amount_interest).'" '.(!empty($line) ? 'disabled title="'.$langs->trans('CantModifyInterestIfScheduleIsUsed').'"' : '').'>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print '-';
|
||||
}
|
||||
print "</td>";
|
||||
print "</td>";
|
||||
|
||||
print "</tr>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
print '<br><div class="center">';
|
||||
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print "</form>\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
|
|
|||
|
|
@ -35,9 +35,15 @@ $action = GETPOST('action', 'aZ09');
|
|||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if (empty($user->rights->loan->calc)) accessforbidden();
|
||||
if (GETPOSTISSET('socid')) {
|
||||
$socid = GETPOST('socid', 'int');
|
||||
}
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->loan->calc)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("compta", "bills", "loan"));
|
||||
|
|
@ -120,7 +126,9 @@ if ($action == 'updateecheancier' && empty($pay_without_schedule)) {
|
|||
$echeances->lines[$i - 1] = $new_echeance;
|
||||
$i++;
|
||||
}
|
||||
if ($result > 0) $db->commit();
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -141,24 +149,23 @@ $morehtmlref = '<div class="refidno">';
|
|||
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->loadLangs(array("projects"));
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
|
||||
if ($user->rights->loan->write)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
if ($user->rights->loan->write) {
|
||||
if ($action != 'classify') {
|
||||
//$morehtmlref .= '<a class="editfielda" 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="'.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);
|
||||
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="'.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)) {
|
||||
|
|
@ -212,14 +219,14 @@ $(document).ready(function() {
|
|||
</script>
|
||||
<?php
|
||||
|
||||
if ($pay_without_schedule == 1)
|
||||
if ($pay_without_schedule == 1) {
|
||||
print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n";
|
||||
}
|
||||
|
||||
print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="loanid" value="'.$loanid.'">';
|
||||
if (count($echeances->lines) > 0)
|
||||
{
|
||||
if (count($echeances->lines) > 0) {
|
||||
print '<input type="hidden" name="action" value="updateecheancier">';
|
||||
} else {
|
||||
print '<input type="hidden" name="action" value="createecheancier">';
|
||||
|
|
@ -229,7 +236,9 @@ print '<div class="div-table-responsive-no-min">';
|
|||
print '<table class="border centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
$colspan = 6;
|
||||
if (count($echeances->lines) > 0) $colspan++;
|
||||
if (count($echeances->lines) > 0) {
|
||||
$colspan++;
|
||||
}
|
||||
print '<th class="center" colspan="'.$colspan.'">';
|
||||
print $langs->trans("FinancialCommitment");
|
||||
print '</th>';
|
||||
|
|
@ -245,18 +254,18 @@ print '<th class="center">'.$langs->trans("CapitalRemain");
|
|||
print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')';
|
||||
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
|
||||
print '</th>';
|
||||
if (count($echeances->lines) > 0) print '<th class="center">'.$langs->trans('DoPayment').'</th>';
|
||||
if (count($echeances->lines) > 0) {
|
||||
print '<th class="center">'.$langs->trans('DoPayment').'</th>';
|
||||
}
|
||||
print '</tr>'."\n";
|
||||
|
||||
if ($object->nbterm > 0 && count($echeances->lines) == 0)
|
||||
{
|
||||
if ($object->nbterm > 0 && count($echeances->lines) == 0) {
|
||||
$i = 1;
|
||||
$capital = $object->capital;
|
||||
$insurance = $object->insurance_amount / $object->nbterm;
|
||||
$insurance = price2num($insurance, 'MT');
|
||||
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
|
||||
while ($i < $object->nbterm + 1)
|
||||
{
|
||||
while ($i < $object->nbterm + 1) {
|
||||
$mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT');
|
||||
$int = ($capital * ($object->rate / 12)) / 100;
|
||||
$int = price2num($int, 'MT');
|
||||
|
|
@ -273,8 +282,7 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0)
|
|||
$i++;
|
||||
$capital = $cap_rest;
|
||||
}
|
||||
} elseif (count($echeances->lines) > 0)
|
||||
{
|
||||
} elseif (count($echeances->lines) > 0) {
|
||||
$i = 1;
|
||||
$capital = $object->capital;
|
||||
$insurance = $object->insurance_amount / $object->nbterm;
|
||||
|
|
@ -300,14 +308,12 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0)
|
|||
|
||||
print '<td class="center" id="capital'.$i.'">'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
|
||||
print '<td class="center">';
|
||||
if (!empty($line->fk_bank))
|
||||
{
|
||||
if (!empty($line->fk_bank)) {
|
||||
print $langs->trans('Paid');
|
||||
if (!empty($line->fk_payment_loan))
|
||||
if (!empty($line->fk_payment_loan)) {
|
||||
print ' <a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>';
|
||||
}
|
||||
elseif (!$printed)
|
||||
{
|
||||
}
|
||||
} elseif (!$printed) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a>';
|
||||
$printed = true;
|
||||
}
|
||||
|
|
@ -323,8 +329,11 @@ print '</div>';
|
|||
|
||||
print '</br>';
|
||||
|
||||
if (count($echeances->lines) == 0) $label = $langs->trans("Create");
|
||||
else $label = $langs->trans("Save");
|
||||
if (count($echeances->lines) == 0) {
|
||||
$label = $langs->trans("Create");
|
||||
} else {
|
||||
$label = $langs->trans("Save");
|
||||
}
|
||||
print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1) ? 'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"' : '').'title=""></div>';
|
||||
print '</form>';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user