Skip to content

Commit

Permalink
Merge branch 'develop' into develop_create_shipmentline
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Apr 8, 2024
2 parents dc93a65 + 1f51287 commit e6dbb0f
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 78 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5107,7 +5107,7 @@ public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account
* @param int<0,3> $outputmode 0=HTML select string, 1=Array with full label only, 2=Array extended, 3=Array with full picto + label
* @param int<0,1> $include [=0] Removed or 1=Keep only
* @param string $morecss More CSS
* @param int<0,2> $useempty 0=No empty value, 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. Default is 1.
* @param int<0,2> $useempty 0=No empty value, 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. Default is 1.
* @return string|array<int,string>|array<int,array{id:int,fulllabel:string,color:string,picto:string}>|array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> String list or Array of categories
* @see select_categories()
*/
Expand Down
15 changes: 11 additions & 4 deletions htdocs/core/class/html.formprojet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ public function select_projects_list($socid = -1, $selected = 0, $htmlname = 'pr
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
* @param string $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more
* @param User $usertofilter User object to use for filtering
* @return int Nbr of tasks if OK, <0 if KO
* @param int $nooutput 1=Return string, do not send to output
*
* @return int|string Nbr of tasks if OK, <0 if KO. If nooutput=1: Return a HTML select string.
*/
public function selectTasks($socid = -1, $selected = 0, $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showmore = 'all', $usertofilter = null)
public function selectTasks($socid = -1, $selected = 0, $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showmore = 'all', $usertofilter = null, $nooutput = 0)
{
global $user, $conf, $langs;

Expand Down Expand Up @@ -508,10 +510,15 @@ public function selectTasks($socid = -1, $selected = 0, $htmlname = 'taskid', $m
}

$this->nboftasks = $num;
$this->db->free($resql);

print $out;
// Output or return
if (empty($nooutput)) {
print $out;
} else {
return $out;
}

$this->db->free($resql);
return $num;
} else {
dol_print_error($this->db);
Expand Down
23 changes: 14 additions & 9 deletions htdocs/fourn/class/fournisseur.facture-rec.class.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2023-2024 Nick Fragoulis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -239,7 +240,6 @@ class FactureFournisseurRec extends CommonInvoice
'revenuestamp' => array('type' => 'double(24,8)', 'label' => 'RevenueStamp', 'enabled' => 1, 'visible' => -1, 'position' => 160, 'isameasure' => 1),
'auto_validate' => array('type' => 'integer', 'label' => 'Auto validate', 'enabled' => 1, 'visible' => -1, 'position' => 165),
'generate_pdf' => array('type' => 'integer', 'label' => 'Generate pdf', 'enabled' => 1, 'visible' => -1, 'position' => 170),

);
// END MODULEBUILDER PROPERTIES

Expand Down Expand Up @@ -300,6 +300,7 @@ public function create($user, $facFournId, $notrigger = 0)
if ($result > 0) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_rec (';
$sql .= 'titre';
$sql .= ", subtype";
$sql .= ', ref_supplier';
$sql .= ', entity';
$sql .= ', fk_soc';
Expand Down Expand Up @@ -330,6 +331,7 @@ public function create($user, $facFournId, $notrigger = 0)
$sql .= ', generate_pdf';
$sql .= ') VALUES (';
$sql .= "'".$this->db->escape($this->title)."'";
$sql .= ", ".($this->subtype ? "'".$this->db->escape($this->subtype)."'" : "null");
$sql .= ", '".$this->db->escape($this->ref_supplier)."'";
$sql .= ", ".((int) $conf->entity);
$sql .= ", ".((int) $facfourn_src->socid);
Expand Down Expand Up @@ -498,6 +500,7 @@ public function update(User $user, $notrigger = 0)

$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET";
$sql .= " titre = '" . (!empty($this->title) ? $this->db->escape($this->title) : "")."'," ;
$sql .= " subtype=".(isset($this->subtype) ? $this->db->escape($this->subtype) : "null").",";
$sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
$sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
if (!empty($this->socid) && $this->socid > 0) {
Expand Down Expand Up @@ -578,7 +581,7 @@ public function update(User $user, $notrigger = 0)
*/
public function fetch($rowid, $ref = '', $ref_ext = '')
{
$sql = 'SELECT f.rowid, f.titre as title, f.ref_supplier, f.entity, f.fk_soc';
$sql = 'SELECT f.rowid, f.titre as title, f.subtype, f.ref_supplier, f.entity, f.fk_soc';
$sql .= ', f.datec, f.tms, f.suspended';
$sql .= ', f.libelle as label';
$sql .= ', f.vat_src_code, f.localtax1, f.localtax2';
Expand Down Expand Up @@ -614,6 +617,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '')
$this->id = $obj->rowid;
$this->titre = $obj->title;
$this->title = $obj->title;
$this->subtype = $obj->subtype;
$this->ref = $obj->title;
$this->ref_supplier = $obj->ref_supplier;
$this->entity = $obj->entity;
Expand Down Expand Up @@ -1338,6 +1342,7 @@ public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidat
$new_fac_fourn->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice

$new_fac_fourn->type = self::TYPE_STANDARD;
$new_fac_fourn->subtype = $facturerec->subtype;
$new_fac_fourn->statut = self::STATUS_DRAFT; // deprecated
$new_fac_fourn->status = self::STATUS_DRAFT;
$new_fac_fourn->date = empty($facturerec->date_when) ? $now : $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
Expand Down
158 changes: 94 additions & 64 deletions htdocs/fourn/facture/card-rec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2023-2024 Nick Fragoulis
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -191,38 +192,38 @@
}

if (! $error) {
$object->titre = GETPOST('title', 'alphanohtml'); // deprecated
$object->title = GETPOST('title', 'alphanohtml');
$object->libelle = GETPOST('libelle', 'alpha'); // deprecated
$object->label = GETPOST('libelle', 'alpha');
$object->fk_project = GETPOSTINT('projectid');
$object->ref_supplier = GETPOST('ref_supplier', 'alphanohtml');

$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->model_pdf = GETPOST('modelpdf', 'alpha');
$object->usenewprice = GETPOST('usenewprice', 'alpha');

$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOSTINT('auto_validate');
$object->generate_pdf = GETPOSTINT('generate_pdf');
$object->subtype = GETPOSTINT('subtype');
$object->title = GETPOST('title', 'alphanohtml');
$object->libelle = GETPOST('libelle', 'alpha'); // deprecated
$object->label = GETPOST('libelle', 'alpha');
$object->fk_project = GETPOSTINT('projectid');
$object->ref_supplier = GETPOST('ref_supplier', 'alphanohtml');

$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->model_pdf = GETPOST('modelpdf', 'alpha');
$object->usenewprice = GETPOST('usenewprice', 'alpha');

$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOSTINT('auto_validate');
$object->generate_pdf = GETPOSTINT('generate_pdf');

$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$object->date_when = $date_next_execution;

$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
$error++;
}


$db->begin();

$oldinvoice = new FactureFournisseur($db);
$oldinvoice->fetch(GETPOSTINT('facid'));

$object->cond_reglement_id = $oldinvoice->cond_reglement_id;
$object->cond_reglement_code = $oldinvoice->cond_reglement_code;
$object->cond_reglement_label = $oldinvoice->cond_reglement_label;
$object->cond_reglement_doc = $oldinvoice->cond_reglement_doc;
$object->mode_reglement_id = $oldinvoice->mode_reglement_id;
$object->mode_reglement_code = $oldinvoice->mode_reglement_code;

$result = $object->create($user, $oldinvoice->id);

Expand Down Expand Up @@ -933,6 +934,13 @@
print '<tr><td class="titlefieldcreate">' . $langs->trans("Customer") . '</td><td>' . $object->thirdparty->getNomUrl(1, 'customer') . '</td>';
print '</tr>';

// Invoice subtype
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', 0, 0, '');
print "</td></tr>";
}

$note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
$note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;

Expand Down Expand Up @@ -965,38 +973,18 @@
print '<input class="flat quatrevingtpercent" type="text" name="libelle" value="' . $object->label . '">';
print '</td></tr>';

// Public note
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '</td>';
print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);

// Private note
if (empty($user->socid)) {
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print '</td>';
print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
}

// Author
print "<tr><td>" . $langs->trans("Author") . "</td><td>" . $user->getFullName($langs) . "</td></tr>";

// Payment term
print "<tr><td>" . $langs->trans("PaymentConditions") . "</td><td>";
$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none');
print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $object->cond_reglement_id, 'cond_reglement_id', -1, 0, 0, '');
print "</td></tr>";

// Payment mode
print "<tr><td>" . $langs->trans("PaymentMode") . "</td><td>";
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none', '', 1);
print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
print "</td></tr>";

// Project
Expand All @@ -1016,13 +1004,46 @@
print "</td></tr>";
}

//extrafields
$draft = new FactureFournisseur($db);
$draft->fetch(GETPOST('facid', 'int'));

$extralabels = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
if ($draft->fetch_optionals() > 0) {
$object->array_options = array_merge($object->array_options, $draft->array_options);
}

print $object->showOptionals($extrafields, 'create', $parameters);

// Model pdf
print "<tr><td>" . $langs->trans('Model') . "</td><td>";
include_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php';
$list = ModelePDFSuppliersInvoices::liste_modeles($db);
print $form->selectarray('modelpdf', $list, $conf->global->INVOICE_SUPPLIER_ADDON_PDF);
print "</td></tr>";

// Public note
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '</td>';
print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);

// Private note
if (empty($user->socid)) {
print '<tr>';
print '<td class="tdtop">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print '</td>';
print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
}

print "</table>";

print dol_get_fiche_end();
Expand Down Expand Up @@ -1195,6 +1216,13 @@

print '<table class="border centpercent tableforfield">';

// Invoice subtype
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
print "<tr><td>".$langs->trans("InvoiceSubtype")."</td><td>";
print $object->getSubtypeLabel('facture_fourn_rec');
print "</td></tr>";
}

print '<tr><td class="titlefield">' . $langs->trans('Author') . '</td><td>';
print $author->getNomUrl(-1);
print "</td></tr>";
Expand Down Expand Up @@ -1335,22 +1363,6 @@
}
$htmltext .= '</i>';

// Note public
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $usercancreate);
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $usercancreate, 'textarea:' . ROWS_4 . ':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';

// Note private
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $usercancreate);
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $usercancreate, 'textarea:' . ROWS_4 . ':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';

// Bank Account
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
Expand All @@ -1369,6 +1381,25 @@
print "</td>";
print '</tr>';

// Extrafields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

// Note public
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';

// Note private
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'));
print '</td><td class="wordbreak">';
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
print '</td>';
print '</tr>';

// Model pdf
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
Expand Down Expand Up @@ -1397,7 +1428,6 @@

// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

print '</table>';

Expand Down
7 changes: 7 additions & 0 deletions htdocs/langs/en_US/projects.lang
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,10 @@ NewLeadbyWeb=Your message or request has been recorded. We will answer or contac
NewLeadForm=New contact form
LeadFromPublicForm=Online lead from public form
ExportAccountingReportButtonLabel=Get report
MergeOriginTask=Duplicate task (task you want to delete)
SelectTask=Select a task
ConfirmMergeTasks=Are you sure you want to merge the chosen task with the current one? All linked objects (invoices, orders, ...) will be moved to the current task, after which the chosen task will be deleted.
MergeTasks=Merge tasks
TaskMergeSuccess=Task have been merged
ErrorTaskIdIsMandatory=Error: Task id is mandatory
ErrorsTaskMerge=Error: An error occurrErrorRecordNotFounded while merging tasks
Loading

0 comments on commit e6dbb0f

Please sign in to comment.