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,14 +408,30 @@ 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)
|
||||||
{
|
{
|
||||||
$ret = $this->add_object_linked($origin, $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, ...))
|
||||||
if (! $ret)
|
{
|
||||||
{
|
foreach($tmp_origin_id as $origin_id)
|
||||||
dol_print_error($this->db);
|
{
|
||||||
$error++;
|
$ret = $this->add_object_linked($origin, $origin_id);
|
||||||
}
|
if (! $ret)
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
$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))
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -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,67 +1402,71 @@ if ($action == 'create')
|
|||||||
print $desc;
|
print $desc;
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (empty($origin))
|
if (empty($origin))
|
||||||
{
|
{
|
||||||
if ($societe->id > 0)
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Need to fix reports of standard accounting module to manage supplier credit note
|
||||||
{
|
{
|
||||||
// Credit note
|
if ($societe->id > 0)
|
||||||
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
|
{
|
||||||
{
|
// Credit note
|
||||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
|
||||||
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
{
|
||||||
if (! $optionsav) $tmp.=' disabled';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp.= '> ';
|
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
|
||||||
// Show credit note options only if we checked credit note
|
if (! $optionsav) $tmp.=' disabled';
|
||||||
print '<script type="text/javascript" language="javascript">
|
$tmp.= '> ';
|
||||||
jQuery(document).ready(function() {
|
// Show credit note options only if we checked credit note
|
||||||
if (! jQuery("#radio_creditnote").is(":checked"))
|
print '<script type="text/javascript" language="javascript">
|
||||||
{
|
jQuery(document).ready(function() {
|
||||||
jQuery("#credit_note_options").hide();
|
if (! jQuery("#radio_creditnote").is(":checked"))
|
||||||
}
|
{
|
||||||
jQuery("#radio_creditnote").click(function() {
|
jQuery("#credit_note_options").hide();
|
||||||
jQuery("#credit_note_options").show();
|
}
|
||||||
});
|
jQuery("#radio_creditnote").click(function() {
|
||||||
jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
|
jQuery("#credit_note_options").show();
|
||||||
jQuery("#credit_note_options").hide();
|
});
|
||||||
});
|
jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
|
||||||
});
|
jQuery("#credit_note_options").hide();
|
||||||
</script>';
|
});
|
||||||
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
});
|
||||||
// $text.='<input type="text" value="">';
|
</script>';
|
||||||
$text .= '<select class="flat" name="fac_avoir" id="fac_avoir"';
|
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
|
||||||
if (! $optionsav)
|
// $text.='<input type="text" value="">';
|
||||||
$text .= ' disabled';
|
$text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
|
||||||
$text .= '>';
|
if (! $optionsav)
|
||||||
if ($optionsav) {
|
$text .= ' disabled';
|
||||||
$text .= '<option value="-1"></option>';
|
$text .= '>';
|
||||||
$text .= $optionsav;
|
if ($optionsav) {
|
||||||
} else {
|
$text .= '<option value="-1"></option>';
|
||||||
$text .= '<option value="-1">' . $langs->trans("NoInvoiceToCorrect") . '</option>';
|
$text .= $optionsav;
|
||||||
}
|
} else {
|
||||||
$text .= '</select>';
|
$text .= '<option value="-1">' . $langs->trans("NoInvoiceToCorrect") . '</option>';
|
||||||
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
|
}
|
||||||
print $desc;
|
$text .= '</select>';
|
||||||
|
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
|
||||||
|
print $desc;
|
||||||
|
|
||||||
print '<div id="credit_note_options" class="clearboth">';
|
print '<div id="credit_note_options" class="clearboth">';
|
||||||
print ' <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
|
print ' <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
|
||||||
print '<br> <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
|
print '<br> <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
|
||||||
$tmp='<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
|
$tmp='<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
|
||||||
$text = $tmp.$langs->trans("InvoiceAvoir") . ' ';
|
$text = $tmp.$langs->trans("InvoiceAvoir") . ' ';
|
||||||
$text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') ';
|
$text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') ';
|
||||||
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
|
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
|
||||||
print $desc;
|
print $desc;
|
||||||
print '</div></div>' . "\n";
|
print '</div></div>' . "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user