NEW When creating a template invoice from a draft invoice, if there is
link to contract on draft invoice, link is kept on template invoice.
This commit is contained in:
parent
d842d05639
commit
3cbeca26e7
@ -163,9 +163,7 @@ class FactureRec extends Facture
|
|||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
|
||||||
|
|
||||||
/*
|
// Add lines
|
||||||
* Lines
|
|
||||||
*/
|
|
||||||
$num=count($facsrc->lines);
|
$num=count($facsrc->lines);
|
||||||
for ($i = 0; $i < $num; $i++)
|
for ($i = 0; $i < $num; $i++)
|
||||||
{
|
{
|
||||||
@ -193,6 +191,20 @@ class FactureRec extends Facture
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add object linked
|
||||||
|
if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
|
||||||
|
{
|
||||||
|
foreach($this->linked_objects as $origin => $origin_id)
|
||||||
|
{
|
||||||
|
$ret = $this->add_object_linked($origin, $origin_id);
|
||||||
|
if (! $ret)
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
@ -205,7 +217,7 @@ class FactureRec extends Facture
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error().' sql='.$sql;
|
$this->error=$this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,9 +122,28 @@ if ($action == 'add')
|
|||||||
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
|
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
|
||||||
$object->date_when = $date_next_execution;
|
$object->date_when = $date_next_execution;
|
||||||
|
|
||||||
|
// Get first contract linked to invoice used to generate template
|
||||||
|
if (GETPOST('facid','int') > 0)
|
||||||
|
{
|
||||||
|
$srcObject = new Facture($db);
|
||||||
|
$srcObject->fetch(GETPOST('facid','int'));
|
||||||
|
|
||||||
|
$srcObject->fetchObjectLinked();
|
||||||
|
|
||||||
|
if (! empty($srcObject->linkedObjectsIds['contrat']))
|
||||||
|
{
|
||||||
|
$contractidid = reset($srcObject->linkedObjectsIds['contrat']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->origin = 'contrat';
|
||||||
|
$object->origin_id = $contractidid;
|
||||||
|
$object->linked_objects[$object->origin] = $object->origin_id;
|
||||||
|
}
|
||||||
|
|
||||||
if ($object->create($user, $id) > 0)
|
if ($object->create($user, $id) > 0)
|
||||||
{
|
{
|
||||||
$id = $object->id;
|
$id = $object->id;
|
||||||
|
|
||||||
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $id);
|
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -932,6 +951,16 @@ else
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
|
|
||||||
|
// Linked object block
|
||||||
|
$somethingshown = $form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
|
print '</div></div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -319,7 +319,6 @@ toolTipFrequency=Examples:<br /><b>Set 7 / day</b>: give a new invoice every 7 d
|
|||||||
NextDateToExecution=Date for next invoice generation
|
NextDateToExecution=Date for next invoice generation
|
||||||
DateLastGeneration=Date of last generation
|
DateLastGeneration=Date of last generation
|
||||||
MaxPeriodNumber=Max nb of invoice generation
|
MaxPeriodNumber=Max nb of invoice generation
|
||||||
RestPeriodNumber=Rest period number
|
|
||||||
NbOfGenerationDone=Nb of invoice generation already done
|
NbOfGenerationDone=Nb of invoice generation already done
|
||||||
InvoiceAutoValidate=Automatically validate invoice
|
InvoiceAutoValidate=Automatically validate invoice
|
||||||
GeneratedFromRecurringInvoice=Generated from template recurring invoice %s
|
GeneratedFromRecurringInvoice=Generated from template recurring invoice %s
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user