NEW Can link template invoice to other objects. Generated invoice will
be linked to same objects.
This commit is contained in:
parent
2f7bdbaab3
commit
d81cd7ebbe
@ -894,7 +894,7 @@ if (empty($reshook))
|
|||||||
// Source facture
|
// Source facture
|
||||||
$object->fac_rec = GETPOST('fac_rec');
|
$object->fac_rec = GETPOST('fac_rec');
|
||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user); // This include recopy of links from recurring invoice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2319,7 +2319,7 @@ if ($action == 'create')
|
|||||||
</script>';
|
</script>';
|
||||||
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
||||||
// $text.='<input type="text" value="">';
|
// $text.='<input type="text" value="">';
|
||||||
$text .= '<select class="flat" name="fac_avoir" id="fac_avoir"';
|
$text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
|
||||||
if (! $optionsav)
|
if (! $optionsav)
|
||||||
$text .= ' disabled';
|
$text .= ' disabled';
|
||||||
$text .= '>';
|
$text .= '>';
|
||||||
|
|||||||
@ -219,9 +219,9 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create invoice in database
|
* Create invoice in database.
|
||||||
* Note: this->ref can be set or empty. If empty, we will use "(PROV)"
|
* Note: this->ref can be set or empty. If empty, we will use "(PROV999)"
|
||||||
* Note: this->fac_rec must be set to create from recurring invoice
|
* Note: this->fac_rec must be set to create invoice from a recurring invoice
|
||||||
*
|
*
|
||||||
* @param User $user Object user that create
|
* @param User $user Object user that create
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0 otherwise
|
* @param int $notrigger 1=Does not execute triggers, 0 otherwise
|
||||||
@ -282,6 +282,7 @@ class Facture extends CommonInvoice
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
|
||||||
$_facrec = new FactureRec($this->db);
|
$_facrec = new FactureRec($this->db);
|
||||||
$result=$_facrec->fetch($this->fac_rec);
|
$result=$_facrec->fetch($this->fac_rec);
|
||||||
|
$result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds
|
||||||
|
|
||||||
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
|
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
|
||||||
$this->entity = $_facrec->entity; // Invoice created in same entity than template
|
$this->entity = $_facrec->entity; // Invoice created in same entity than template
|
||||||
@ -312,6 +313,9 @@ class Facture extends CommonInvoice
|
|||||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
|
|
||||||
|
$this->linked_objects = $_facrec->linkedObjectsIds;
|
||||||
|
var_dump($this->linked_objects);
|
||||||
|
|
||||||
$forceduedate = $this->calculate_date_lim_reglement();
|
$forceduedate = $this->calculate_date_lim_reglement();
|
||||||
|
|
||||||
// For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice
|
// For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice
|
||||||
@ -404,7 +408,11 @@ class Facture extends CommonInvoice
|
|||||||
// Add object linked
|
// Add object linked
|
||||||
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
|
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
|
||||||
{
|
{
|
||||||
foreach($this->linked_objects as $origin => $origin_id)
|
foreach($this->linked_objects as $origin => $tmp_origin_id)
|
||||||
|
{
|
||||||
|
if (is_array($tmp_origin_id)) // New baheviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
|
||||||
|
{
|
||||||
|
foreach($tmp_origin_id as $origin_id)
|
||||||
{
|
{
|
||||||
$ret = $this->add_object_linked($origin, $origin_id);
|
$ret = $this->add_object_linked($origin, $origin_id);
|
||||||
if (! $ret)
|
if (! $ret)
|
||||||
@ -412,6 +420,18 @@ class Facture extends CommonInvoice
|
|||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
|
||||||
|
{
|
||||||
|
$origin_id = $tmp_origin_id;
|
||||||
|
$ret = $this->add_object_linked($origin, $origin_id);
|
||||||
|
if (! $ret)
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
|
if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -87,11 +87,11 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('invoicecard','globalcard'));
|
$hookmanager->initHooks(array('invoicereccard','globalcard'));
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label('facturerec');
|
$extralabels = $extrafields->fetch_name_optionals_label('facture');
|
||||||
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||||
|
|
||||||
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||||
@ -124,12 +124,38 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$parameters = array('socid' => $socid);
|
||||||
|
$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 (GETPOST('cancel')) $action='';
|
||||||
|
|
||||||
// Set note
|
// Set note
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
if (GETPOST('cancel')) $action='';
|
// Do we click on purge search criteria ?
|
||||||
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
||||||
|
{
|
||||||
|
$search_ref='';
|
||||||
|
$search_societe='';
|
||||||
|
$search_montant_ht='';
|
||||||
|
$search_montant_vat='';
|
||||||
|
$search_montant_ttc='';
|
||||||
|
$day='';
|
||||||
|
$year='';
|
||||||
|
$month='';
|
||||||
|
$day_date_when='';
|
||||||
|
$year_date_when='';
|
||||||
|
$month_date_when='';
|
||||||
|
$search_frequency='';
|
||||||
|
$search_array_options=array();
|
||||||
|
}
|
||||||
|
|
||||||
// Create predefined invoice
|
// Create predefined invoice
|
||||||
if ($action == 'add')
|
if ($action == 'add')
|
||||||
@ -826,27 +852,9 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we click on purge search criteria ?
|
|
||||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
|
||||||
{
|
|
||||||
$search_ref='';
|
|
||||||
$search_societe='';
|
|
||||||
$search_montant_ht='';
|
|
||||||
$search_montant_vat='';
|
|
||||||
$search_montant_ttc='';
|
|
||||||
$day='';
|
|
||||||
$year='';
|
|
||||||
$month='';
|
|
||||||
$day_date_when='';
|
|
||||||
$year_date_when='';
|
|
||||||
$month_date_when='';
|
|
||||||
$search_frequency='';
|
|
||||||
$search_array_options=array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -1420,8 +1428,9 @@ else
|
|||||||
|
|
||||||
|
|
||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
|
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
|
||||||
$somethingshown = $form->showLinkedObjectBlock($object, '');
|
|
||||||
|
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||||
|
|
||||||
|
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
|
|||||||
@ -1322,6 +1322,7 @@ if ($action == 'create')
|
|||||||
print $desc;
|
print $desc;
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
|
|
||||||
|
/* Not yet supported
|
||||||
if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid))))
|
if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid))))
|
||||||
{
|
{
|
||||||
// Deposit
|
// Deposit
|
||||||
@ -1354,7 +1355,9 @@ if ($action == 'create')
|
|||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Not yet supporter for supplier
|
||||||
if ($societe->id > 0)
|
if ($societe->id > 0)
|
||||||
{
|
{
|
||||||
// Replacement
|
// Replacement
|
||||||
@ -1399,8 +1402,11 @@ if ($action == 'create')
|
|||||||
print $desc;
|
print $desc;
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (empty($origin))
|
if (empty($origin))
|
||||||
|
{
|
||||||
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Need to fix reports of standard accounting module to manage supplier credit note
|
||||||
{
|
{
|
||||||
if ($societe->id > 0)
|
if ($societe->id > 0)
|
||||||
{
|
{
|
||||||
@ -1428,7 +1434,7 @@ if ($action == 'create')
|
|||||||
</script>';
|
</script>';
|
||||||
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
||||||
// $text.='<input type="text" value="">';
|
// $text.='<input type="text" value="">';
|
||||||
$text .= '<select class="flat" name="fac_avoir" id="fac_avoir"';
|
$text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
|
||||||
if (! $optionsav)
|
if (! $optionsav)
|
||||||
$text .= ' disabled';
|
$text .= ' disabled';
|
||||||
$text .= '>';
|
$text .= '>';
|
||||||
@ -1461,6 +1467,7 @@ if ($action == 'create')
|
|||||||
print '</div></div>' . "\n";
|
print '</div></div>' . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user