29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/modules/salaries/modules_salary.php';
41 public $element =
'salary';
51 public $table_element =
'salary';
56 public $module =
'salaries';
61 public $picto =
'salary';
66 protected $childtables = array(
'payment_salary' => array(
'name' =>
'SalaryPayment',
'fk_element' =>
'fk_salary'));
107 public $type_payment;
111 public $type_payment_code;
152 public $fk_user_author;
157 public $fk_user_modif;
175 const STATUS_UNPAID = 0;
176 const STATUS_PAID = 1;
179 public $fields = array(
180 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id'),
181 'ref' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref',
'enabled' => 1,
'position' => 10,
'visible' => 1,
'index' => 1,
'comment' =>
"Reference of object"),
182 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'RefExt',
'enabled' => 1,
'visible' => 0,
'position' => 11),
183 'label' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'position' => 12,
'notnull' => 0,
'visible' => 1),
184 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => 0,
'position' => 30),
185 'datep' => array(
'type' =>
'date',
'label' =>
'Date',
'enabled' => 1,
'visible' => 0,
'position' => 40,
'comment' =>
'Date'),
186 'datev' => array(
'type' =>
'date',
'label' =>
'Date',
'enabled' => 1,
'visible' => 0,
'position' => 50,
'comment' =>
'Date'),
187 'fk_user' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Employee',
'enabled' => 1,
'position' => 15,
'notnull' => 1,
'visible' => 1,
'picto' =>
'user'),
188 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 20),
189 'salary' => array(
'type' =>
'double(24,8)',
'label' =>
'salary',
'enabled' => 1,
'visible' => 0,
'position' => 70),
190 'amount' => array(
'type' =>
'double(24,8)',
'label' =>
'Amount',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 80),
191 'fk_projet' => array(
'type' =>
'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)',
'label' =>
'Project',
'enabled' =>
"isModEnabled('project')",
'visible' => 0,
'position' => 90),
192 'fk_typepayment' => array(
'type' =>
'typepayment',
'label' =>
'DefaultPaymentMode',
'enabled' => 1,
'visible' => 1,
'position' => 100,
'comment' =>
'Payment type'),
193 'num_payment' => array(
'type' =>
'string',
'label' =>
'Reference',
'enabled' => 1,
'visible' => 0,
'position' => 110,
'comment' =>
'Reference'),
194 'datesp' => array(
'type' =>
'date',
'label' =>
'DateStart',
'enabled' => 1,
'visible' => 1,
'position' => 130,
'comment' =>
'Date'),
195 'dateep' => array(
'type' =>
'date',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 140,
'comment' =>
'Date'),
196 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => 0,
'position' => 150,
'index' => 1),
197 'note' => array(
'type' =>
'text',
'label' =>
'Note',
'enabled' => 1,
'position' => 160,
'visible' => 0,),
198 'fk_bank' => array(
'type' =>
'integer',
'label' =>
'BankId',
'enabled' => 1,
'visible' => 0,
'position' => 170),
199 'paye' => array(
'type' =>
'smallint(6)',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 180),
200 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => 0,
'position' => 190),
201 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 200,
'visible' => 0,),
202 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 220),
214 $this->element =
'salary';
215 $this->table_element =
'salary';
216 $this->isextrafieldmanaged = 1;
218 $this->fields[
'ref_ext'][
'visible'] =
getDolGlobalInt(
'MAIN_LIST_SHOW_REF_EXT');
232 public function generateDocument($model, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = array())
234 global
$conf, $langs;
237 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Model"));
238 $this->errors[] = $this->error;
242 $modelpath =
'core/modules/salaries/doc/';
243 $modelfile = $modelpath.
"pdf_".$model.
".modules.php";
246 if (file_exists(DOL_DOCUMENT_ROOT.
'/'.$modelfile)) {
247 require_once DOL_DOCUMENT_ROOT.
'/'.$modelfile;
249 $classname =
'pdf_'.$model;
250 if (class_exists($classname)) {
251 $module =
new $classname($this->db);
255 $result = $module->writeFile($this, $outputlangs);
258 if (!empty($module->result[
'fullpath'])) {
260 $this->
indexFile($module->result[
'fullpath'], (empty($module->update_main_doc_field) ? 0 : 1));
263 dol_syslog(
'Method ->writeFile was called on object '.get_class($module).
' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
268 $this->error = $module->error;
269 $this->errors = $module->errors;
273 $this->error =
'Failed to load class '.$classname;
274 $this->errors[] = $this->error;
278 $this->error = $langs->trans(
"ErrorModuleNotFound", $model);
279 $this->errors[] = $this->error;
291 public function update($user =
null, $notrigger = 0)
297 $this->label = trim((
string) $this->label);
298 $this->note = trim((
string) $this->note);
299 $this->note_private = trim((
string) $this->note_private);
300 $this->note_public = trim((
string) $this->note_public);
303 if (empty($this->fk_user) || $this->fk_user < 0) {
304 $this->error =
'ErrorBadParameter';
311 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"salary SET";
312 $sql .=
" tms='".$this->db->idate(
dol_now()).
"',";
313 $sql .=
" fk_user=".((int) $this->fk_user).
",";
316 $sql .=
" amount=".price2num($this->amount).
",";
317 $sql .=
" fk_projet=".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null").
",";
318 $sql .=
" fk_typepayment=".((int) $this->type_payment).
",";
319 $sql .=
" label='".$this->db->escape($this->label).
"',";
320 $sql .=
" datesp='".$this->db->idate($this->datesp).
"',";
321 $sql .=
" dateep='".$this->db->idate($this->dateep).
"',";
322 $sql .=
" note='".$this->db->escape($this->note).
"',";
323 $sql .=
" fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank :
"null").
",";
324 $sql .=
" fk_user_author=".((int) $this->fk_user_author).
",";
325 $sql .=
" fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id);
326 $sql .=
" WHERE rowid=".((int) $this->
id);
328 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
329 $resql = $this->db->query($sql);
331 $this->error =
"Error ".$this->db->lasterror();
343 $result = $this->call_trigger(
'SALARY_MODIFY', $user);
354 $this->db->rollback();
367 public function fetch($id, $user =
null)
372 $sql .=
" s.fk_user,";
375 $sql .=
" s.amount,";
376 $sql .=
" s.fk_projet as fk_project,";
377 $sql .=
" s.fk_typepayment,";
379 $sql .=
" s.datesp,";
380 $sql .=
" s.dateep,";
381 $sql .=
" s.note as note_private,";
382 $sql .=
" s.note_public,";
384 $sql .=
" s.fk_bank,";
385 $sql .=
" s.fk_user_author,";
386 $sql .=
" s.fk_user_modif,";
387 $sql .=
" s.fk_account,";
388 $sql .=
" cp.code as type_payment_code";
389 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s";
390 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON s.fk_bank = b.rowid";
391 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON s.fk_typepayment = cp.id";
392 $sql .=
" WHERE s.rowid = ".((int) $id);
394 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
396 $resql = $this->db->query($sql);
398 if ($this->db->num_rows($resql)) {
399 $obj = $this->db->fetch_object($resql);
401 $this->
id = $obj->rowid;
402 $this->
ref = $obj->rowid;
403 $this->tms = $this->db->jdate($obj->tms);
404 $this->fk_user = $obj->fk_user;
405 $this->datep = $this->db->jdate($obj->datep);
406 $this->datev = $this->db->jdate($obj->datev);
407 $this->
amount = $obj->amount;
408 $this->fk_project = $obj->fk_project;
409 $this->type_payment = $obj->fk_typepayment;
410 $this->type_payment_code = $obj->type_payment_code;
411 $this->label = $obj->label;
412 $this->datesp = $this->db->jdate($obj->datesp);
413 $this->dateep = $this->db->jdate($obj->dateep);
414 $this->note = $obj->note_private;
415 $this->note_private = $obj->note_private;
416 $this->note_public = $obj->note_public;
417 $this->paye = $obj->paye;
418 $this->
status = $obj->paye;
419 $this->fk_bank = $obj->fk_bank;
420 $this->fk_user_author = $obj->fk_user_author;
421 $this->fk_user_modif = $obj->fk_user_modif;
422 $this->fk_account = $obj->fk_account;
423 $this->accountid = $obj->fk_account;
429 $this->db->free($resql);
433 $this->error =
"Error ".$this->db->lasterror();
446 public function delete($user, $notrigger = 0)
473 $this->fk_user_author = 0;
474 $this->fk_user_modif = 0;
487 global
$conf, $langs;
494 $this->label = trim((
string) $this->label);
495 $this->note = trim((
string) $this->note);
496 $this->fk_bank = (int) $this->fk_bank;
497 $this->fk_user_author = (int) $this->fk_user_author;
498 $this->fk_user_modif = (int) $this->fk_user_modif;
499 $this->accountid = (int) $this->accountid;
500 $this->paye = (int) $this->paye;
504 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
507 if ($this->fk_user < 0 || $this->fk_user ==
'') {
508 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Employee"));
511 if ($this->amount ==
'') {
512 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
519 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"salary (fk_user";
523 $sql .=
", fk_projet";
525 $sql .=
", fk_typepayment";
526 $sql .=
", fk_account";
533 $sql .=
", fk_user_author";
539 $sql .= ((int) $this->fk_user);
542 $sql .=
", ".((float) $this->amount);
543 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
544 $sql .=
", ".($this->salary > 0 ? ((float) $this->salary) :
"null");
545 $sql .=
", ".($this->type_payment > 0 ? ((int) $this->type_payment) : 0);
546 $sql .=
", ".($this->accountid > 0 ? ((int) $this->accountid) :
"null");
548 $sql .=
", '".$this->db->escape($this->note).
"'";
550 $sql .=
", '".$this->db->escape($this->label).
"'";
551 $sql .=
", '".$this->db->idate($this->datesp).
"'";
552 $sql .=
", '".$this->db->idate($this->dateep).
"'";
553 $sql .=
", ".((int) $user->id);
554 $sql .=
", '".$this->db->idate($now).
"'";
556 $sql .=
", ".((int)
$conf->entity);
559 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
560 $result = $this->db->query($sql);
562 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"salary");
572 $result = $this->call_trigger(
'SALARY_CREATE', $user);
585 $this->db->rollback();
589 $this->error = $this->db->error();
590 $this->db->rollback();
605 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'salary SET fk_bank = '.((int) $id_bank);
606 $sql .=
" WHERE rowid = ".((int) $this->
id);
607 $result = $this->db->query($sql);
626 $langs->loadLangs([
'salaries']);
629 if (!empty($params[
'fromajaxtooltip']) && !isset($this->alreadypaid)) {
636 $datas[
'picto'] =
'<u>'.$langs->trans(
"Salary").
'</u>';
637 if (isset($this->
status) && isset($this->alreadypaid)) {
638 $datas[
'picto'] .=
' '.$this->getLibStatut(5, $this->alreadypaid);
640 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
655 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
657 global
$conf, $langs, $hookmanager;
659 if (!empty(
$conf->dol_no_mouse_hover)) {
666 'objecttype' => $this->element,
669 $classfortooltip =
'classfortooltip';
672 $classfortooltip =
'classforajaxtooltip';
673 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
679 $url = DOL_URL_ROOT.
'/salaries/card.php?id='.$this->id;
681 if ($option !=
'nolink') {
683 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
684 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
685 $add_save_lastsearch_values = 1;
687 if ($add_save_lastsearch_values) {
688 $url .=
'&save_lastsearch_values=1';
693 if (empty($notooltip)) {
695 $label = $langs->trans(
"ShowMyObject");
696 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
698 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
699 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
701 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
704 $linkstart =
'<a href="'.$url.
'"';
705 $linkstart .= $linkclose.
'>';
708 $result .= $linkstart;
710 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
712 if ($withpicto != 2) {
713 $result .= $this->ref;
718 global $action, $hookmanager;
719 $hookmanager->initHooks(array(
'salarypayment'));
720 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
721 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
723 $result = $hookmanager->resPrint;
725 $result .= $hookmanager->resPrint;
739 $sql =
"SELECT sum(amount) as amount";
741 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary";
742 $sql .=
" WHERE fk_salary = ".((int) $this->
id);
744 dol_syslog(get_class($this).
"::getSommePaiement for salary id=".((
int) $this->
id), LOG_DEBUG);
746 $resql = $this->db->query($sql);
749 $obj = $this->db->fetch_object($resql);
751 $this->db->free($resql);
754 if ($multicurrency < 0) {
759 } elseif ($multicurrency) {
765 return (
float) $obj->amount;
771 $this->error = $this->db->lasterror();
784 $sql =
'SELECT ps.rowid, ps.datec, ps.tms as datem, ps.fk_user_author, ps.fk_user_modif';
785 $sql .=
' FROM '.MAIN_DB_PREFIX.
'salary as ps';
786 $sql .=
' WHERE ps.rowid = '.((int) $id);
788 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
789 $result = $this->db->query($sql);
792 if ($this->db->num_rows($result)) {
793 $obj = $this->db->fetch_object($result);
795 $this->
id = $obj->rowid;
797 $this->user_creation_id = $obj->fk_user_author;
798 $this->user_modification_id = $obj->fk_user_modif;
799 $this->date_creation = $this->db->jdate($obj->datec);
800 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
802 $this->db->free($result);
820 dol_syslog(get_class($this).
"::set_paid is deprecated, use setPaid instead", LOG_NOTICE);
832 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"salary SET";
834 $sql .=
" WHERE rowid = ".((int) $this->
id);
836 $return = $this->db->query($sql);
856 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"salary SET";
858 $sql .=
" WHERE rowid = ".((int) $this->
id);
860 $return = $this->db->query($sql);
880 return $this->
LibStatut($this->paye, $mode, $alreadypaid);
892 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
898 $langs->loadLangs(array(
"customers",
"bills"));
901 $this->labelStatus = array();
902 $this->labelStatusShort = array();
904 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
907 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv(
'BillStatusNotPaid');
908 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv(
'BillStatusPaid');
909 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
910 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv(
"BillStatusStarted");
912 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv(
'BillStatusNotPaid');
913 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv(
'BillStatusPaid');
914 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
915 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv(
"BillStatusStarted");
919 $statusType =
'status1';
920 if ($status == 0 && $alreadypaid != 0) {
921 $statusType =
'status3';
924 $statusType =
'status6';
927 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
937 public function getKanbanView($option =
'', $arraydata =
null)
941 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
943 $return =
'<div class="box-flex-item box-flex-grow-zero">';
944 $return .=
'<div class="info-box info-box-sm">';
945 $return .=
'<span class="info-box-icon bg-infobox-action">';
947 $return .=
'</span>';
948 $return .=
'<div class="info-box-content">';
949 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->
getNomUrl(1) .
'</span>';
950 if ($selected >= 0) {
951 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
953 if (!empty($arraydata[
'user']) && is_object($arraydata[
'user'])) {
954 $user = $arraydata[
'user'];
955 '@phan-var-force User $user';
957 $return .=
'<br><span class="info-box-label">'.$user->getNomUrl(empty($arraydata[
'user']->photo) ? 1 : -1,
'', 0, 0, 16, 0,
'',
'maxwidth100').
'</span>';
959 $return .=
'<br><span class="info-box-label amount">'.price($this->
amount).
'</span>';
960 if (!empty($this->type_payment)) {
961 $return .=
' <span class="info-box-label opacitymedium small">';
962 if ($langs->trans(
"PaymentTypeShort".$this->type_payment) !=
"PaymentTypeShort".$this->type_payment) {
963 $return .= $langs->trans(
"PaymentTypeShort".$this->type_payment);
964 } elseif ($langs->trans(
"PaymentType".$this->type_payment) !=
"PaymentType".$this->type_payment) {
965 $return .= $langs->trans(
"PaymentType".$this->type_payment);
967 $return .=
'</span>';
969 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3, isset($this->alreadypaid) ? $this->alreadypaid : $this->totalpaid).
'</div>';
989 public function demande_prelevement($fuser, $amount = 0, $type =
'direct-debit', $sourcetype =
'salaire', $checkduplicateamongall = 0)
996 dol_syslog(get_class($this).
"::demande_prelevement", LOG_DEBUG);
997 if ($this->paye == 0) {
998 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1001 $bac->fetch(0,
'',
$mysoc->id);
1003 $sql =
"SELECT count(rowid) as nb";
1004 $sql .=
" FROM ".$this->db->prefix().
"prelevement_demande";
1005 if ($type ==
'salaire') {
1006 $sql .=
" WHERE fk_salary = ".((int) $this->
id);
1008 $sql .=
" WHERE fk_facture = ".((int) $this->
id);
1010 $sql .=
" AND type = 'ban'";
1011 if (empty($checkduplicateamongall)) {
1012 $sql .=
" AND traite = 0";
1015 dol_syslog(get_class($this).
"::demande_prelevement", LOG_DEBUG);
1017 $resql = $this->db->query($sql);
1019 $obj = $this->db->fetch_object($resql);
1020 if ($obj && $obj->nb == 0) {
1036 if (is_numeric($amount) && $amount != 0) {
1037 $sql =
'INSERT INTO '.$this->db->prefix().
'prelevement_demande(';
1038 if ($type ==
'salaire') {
1039 $sql .=
'fk_salary, ';
1041 $sql .=
'fk_facture, ';
1043 $sql .=
' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, type, entity)';
1044 $sql .=
" VALUES (".((int) $this->
id);
1045 $sql .=
", ".((float)
price2num($amount));
1046 $sql .=
", '".$this->db->idate($now).
"'";
1047 $sql .=
", ".((int) $fuser->id);
1048 $sql .=
", '".$this->db->escape($bac->code_banque).
"'";
1049 $sql .=
", '".$this->db->escape($bac->code_guichet).
"'";
1050 $sql .=
", '".$this->db->escape($bac->number).
"'";
1051 $sql .=
", '".$this->db->escape($bac->cle_rib).
"'";
1052 $sql .=
", '".$this->db->escape($sourcetype).
"'";
1054 $sql .=
", ".((int)
$conf->entity);
1057 dol_syslog(get_class($this).
"::demande_prelevement", LOG_DEBUG);
1058 $resql = $this->db->query($sql);
1060 $this->error = $this->db->lasterror();
1061 dol_syslog(get_class($this).
'::demandeprelevement Erreur');
1065 $this->error =
'WithdrawRequestErrorNilAmount';
1066 dol_syslog(get_class($this).
'::demandeprelevement WithdrawRequestErrorNilAmount');
1072 $payment_mode_id =
dol_getIdFromCode($this->db, (($type ==
'bank-transfer' || $type ==
'salaire') ?
'VIR' :
'PRE'),
'c_paiement',
'code',
'id', 1);
1073 if ($payment_mode_id > 0) {
1083 $this->error =
"A request already exists";
1084 dol_syslog(get_class($this).
'::demandeprelevement Can t create a request to generate a direct debit, a request already exists.');
1088 $this->error = $this->db->error();
1089 dol_syslog(get_class($this).
'::demandeprelevement Error -2');
1093 $this->error =
"Status of invoice does not allow this";
1094 dol_syslog(get_class($this).
"::demandeprelevement ".$this->error.
" $this->status, $this->paye, $this->mode_reglement_id");
1110 $sql =
'DELETE FROM '.$this->db->prefix().
'prelevement_demande';
1111 $sql .=
' WHERE rowid = '.((int) $did);
1112 $sql .=
' AND traite = 0';
1113 if ($this->db->query($sql)) {
1116 $this->error = $this->db->lasterror();
1117 dol_syslog(get_class($this).
'::demande_prelevement_delete Error '.$this->error);
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
indexFile($destfull, $update_main_doc_field)
Index a file into the ECM database.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
setPaymentMethods($id)
Change the payments methods.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage bank accounts description of third parties.
Class to manage salary payments.
fetch($id, $user=null)
Load object in memory from database.
initAsSpecimen()
Initialise an instance with random values.
update($user=null, $notrigger=0)
Update database.
getTooltipContentArray($params)
getTooltipContentArray
update_fk_bank($id_bank)
Update link between payment salary and line generate into llx_bank.
LibStatut($status, $mode=0, $alreadypaid=-1)
Return label of a given status.
set_paid($user)
Tag social contribution as paid completely.
generateDocument($model, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=array())
Generate a document from a model.
demande_prelevement_delete($fuser, $did)
Remove a direct debit request or a credit transfer request.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Send name clickable (with possibly the picto)
set_unpaid($user)
Remove tag paid on social contribution.
create($user)
Create in database.
getSommePaiement($multicurrency=0)
Return amount of payments already done.
getLibStatut($mode=0, $alreadypaid=-1)
Return label of current status.
info($id)
Information on record.
__construct($db)
Constructor.
setPaid($user)
Tag social contribution as paid completely.
demande_prelevement($fuser, $amount=0, $type='direct-debit', $sourcetype='salaire', $checkduplicateamongall=0)
Create a withdrawal request for a direct debit order or a credit transfer order.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_is_file($pathoffile)
Return if path is a file.
dol_now($mode='gmt')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount