NEW Upload file with drag and drop for VATs
This commit is contained in:
parent
f61f425231
commit
c4dc0b3c35
@ -15,6 +15,7 @@ NEW: Accountancy - Add specific page to export accounting data rather than the j
|
|||||||
NEW: Accountancy - Add sub-account balance FPC22
|
NEW: Accountancy - Add sub-account balance FPC22
|
||||||
NEW: Accountancy - Manage customer retained warranty FPC21+
|
NEW: Accountancy - Manage customer retained warranty FPC21+
|
||||||
NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22
|
NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22
|
||||||
|
NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions
|
||||||
NEW: adapt category and product pictures sizes on takepos
|
NEW: adapt category and product pictures sizes on takepos
|
||||||
NEW: Add ability of ODT support to supplier invoices
|
NEW: Add ability of ODT support to supplier invoices
|
||||||
NEW: Add a public virtual card page for each user
|
NEW: Add a public virtual card page for each user
|
||||||
|
|||||||
@ -453,9 +453,6 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// View mode
|
// View mode
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
$object = new ChargeSociales($db);
|
|
||||||
$result = $object->fetch($id);
|
|
||||||
|
|
||||||
$formconfirm = '';
|
$formconfirm = '';
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
|
|||||||
@ -43,9 +43,9 @@ if (isModEnabled('accounting')) {
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('compta', 'banks', 'bills'));
|
$langs->loadLangs(array('compta', 'banks', 'bills'));
|
||||||
|
|
||||||
$id = GETPOST("id", 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$ref = GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
$action = GETPOST("action", "aZ09");
|
$action = GETPOST('action', 'aZ09');
|
||||||
$confirm = GETPOST('confirm', 'alpha');
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
$cancel = GETPOST('cancel', 'aZ09');
|
$cancel = GETPOST('cancel', 'aZ09');
|
||||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
|
||||||
@ -80,8 +80,8 @@ if (empty($action) && empty($id) && empty($ref)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load object
|
// Load object
|
||||||
if ($id > 0) {
|
if ($id > 0 || $ref) {
|
||||||
$object->fetch($id);
|
$object->fetch($id, $ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
$permissiontoread = $user->rights->tax->charges->lire;
|
$permissiontoread = $user->rights->tax->charges->lire;
|
||||||
@ -96,277 +96,282 @@ $socid = GETPOST('socid', 'int');
|
|||||||
if ($user->socid) {
|
if ($user->socid) {
|
||||||
$socid = $user->socid;
|
$socid = $user->socid;
|
||||||
}
|
}
|
||||||
$result = restrictedArea($user, 'tax', '', 'tva', 'charges');
|
$result = restrictedArea($user, 'tax', $object->id, 'tva', 'charges');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array('socid' => $socid);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) {
|
if ($reshook < 0) {
|
||||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cancel && !$id) {
|
if (empty($reshook)) {
|
||||||
header("Location: list.php");
|
if ($cancel && !$id) {
|
||||||
exit;
|
header("Location: list.php");
|
||||||
}
|
exit;
|
||||||
|
|
||||||
if ($action == 'setlib' && $user->rights->tax->charges->creer) {
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY');
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'setdatev' && $user->rights->tax->charges->creer) {
|
|
||||||
$object->fetch($id);
|
|
||||||
$object->datev = $datev;
|
|
||||||
$result = $object->update($user);
|
|
||||||
if ($result < 0) {
|
|
||||||
dol_print_error($db, $object->error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = '';
|
if ($action == 'setlib' && $user->rights->tax->charges->creer) {
|
||||||
}
|
$object->fetch($id);
|
||||||
|
$result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY');
|
||||||
// payment mode
|
if ($result < 0) {
|
||||||
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bank account
|
|
||||||
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Classify paid
|
|
||||||
if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') {
|
|
||||||
$object->fetch($id);
|
|
||||||
$result = $object->setPaid($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'reopen' && $user->rights->tax->charges->creer) {
|
|
||||||
$result = $object->fetch($id);
|
|
||||||
if ($object->paye) {
|
|
||||||
$result = $object->setUnpaid($user);
|
|
||||||
if ($result > 0) {
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'add' && !$cancel) {
|
if ($action == 'setdatev' && $user->rights->tax->charges->creer) {
|
||||||
$error = 0;
|
$object->fetch($id);
|
||||||
|
$object->datev = $datev;
|
||||||
|
$result = $object->update($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
dol_print_error($db, $object->error);
|
||||||
|
}
|
||||||
|
|
||||||
$object->fk_account = GETPOST("accountid", 'int');
|
$action = '';
|
||||||
$object->type_payment = GETPOST("type_payment", 'alphanohtml');
|
|
||||||
$object->num_payment = GETPOST("num_payment", 'alphanohtml');
|
|
||||||
|
|
||||||
$object->datev = $datev;
|
|
||||||
$object->datep = $datep;
|
|
||||||
|
|
||||||
$amount = price2num(GETPOST("amount", 'alpha'));
|
|
||||||
if ($refund == 1) {
|
|
||||||
$amount = -$amount;
|
|
||||||
}
|
|
||||||
$object->amount = $amount;
|
|
||||||
$object->label = GETPOST("label", 'alpha');
|
|
||||||
$object->note = GETPOST("note", 'restricthtml');
|
|
||||||
$object->note_private = GETPOST("note", 'restricthtml');
|
|
||||||
|
|
||||||
if (empty($object->datep)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if (empty($object->datev)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if (!empty($auto_create_payment) && (empty($object->type_payment) || $object->type_payment < 0)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if (empty($object->amount)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if (!empty($auto_create_payment) && ($object->fk_account <= 0)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountToCredit")), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
// payment mode
|
||||||
$ret = $object->create($user);
|
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
|
||||||
if ($ret < 0) {
|
$object->fetch($id);
|
||||||
|
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bank account
|
||||||
|
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
||||||
|
$object->fetch($id);
|
||||||
|
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classify paid
|
||||||
|
if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') {
|
||||||
|
$object->fetch($id);
|
||||||
|
$result = $object->setPaid($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'reopen' && $user->rights->tax->charges->creer) {
|
||||||
|
$result = $object->fetch($id);
|
||||||
|
if ($object->paye) {
|
||||||
|
$result = $object->setUnpaid($user);
|
||||||
|
if ($result > 0) {
|
||||||
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'add' && !$cancel) {
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$object->fk_account = GETPOST("accountid", 'int');
|
||||||
|
$object->type_payment = GETPOST("type_payment", 'alphanohtml');
|
||||||
|
$object->num_payment = GETPOST("num_payment", 'alphanohtml');
|
||||||
|
|
||||||
|
$object->datev = $datev;
|
||||||
|
$object->datep = $datep;
|
||||||
|
|
||||||
|
$amount = price2num(GETPOST("amount", 'alpha'));
|
||||||
|
if ($refund == 1) {
|
||||||
|
$amount = -$amount;
|
||||||
|
}
|
||||||
|
$object->amount = $amount;
|
||||||
|
$object->label = GETPOST("label", 'alpha');
|
||||||
|
$object->note = GETPOST("note", 'restricthtml');
|
||||||
|
$object->note_private = GETPOST("note", 'restricthtml');
|
||||||
|
|
||||||
|
if (empty($object->datep)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (empty($object->datev)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (!empty($auto_create_payment) && (empty($object->type_payment) || $object->type_payment < 0)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (empty($object->amount)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (!empty($auto_create_payment) && ($object->fk_account <= 0)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountToCredit")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto create payment
|
if (!$error) {
|
||||||
if (!empty($auto_create_payment) && !$error) {
|
$ret = $object->create($user);
|
||||||
$db->begin();
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a line of payments
|
// Auto create payment
|
||||||
$paiement = new PaymentVAT($db);
|
if (!empty($auto_create_payment) && !$error) {
|
||||||
$paiement->chid = $object->id;
|
$db->begin();
|
||||||
$paiement->datepaye = $datep;
|
|
||||||
$paiement->amounts = array($object->id=>$amount); // Tableau de montant
|
|
||||||
$paiement->paiementtype = GETPOST("type_payment", 'alphanohtml');
|
|
||||||
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
|
|
||||||
$paiement->note = GETPOST("note", 'restricthtml');
|
|
||||||
|
|
||||||
if (!$error) {
|
// Create a line of payments
|
||||||
$paymentid = $paiement->create($user, (int) GETPOST('closepaidtva'));
|
$paiement = new PaymentVAT($db);
|
||||||
if ($paymentid < 0) {
|
$paiement->chid = $object->id;
|
||||||
$error++;
|
$paiement->datepaye = $datep;
|
||||||
setEventMessages($paiement->error, null, 'errors');
|
$paiement->amounts = array($object->id=>$amount); // Tableau de montant
|
||||||
$action = 'create';
|
$paiement->paiementtype = GETPOST("type_payment", 'alphanohtml');
|
||||||
|
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
|
||||||
|
$paiement->note = GETPOST("note", 'restricthtml');
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$paymentid = $paiement->create($user, (int) GETPOST('closepaidtva'));
|
||||||
|
if ($paymentid < 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($paiement->error, null, 'errors');
|
||||||
|
$action = 'create';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', '');
|
||||||
|
if (!($result > 0)) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($paiement->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$db->commit();
|
||||||
|
} else {
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (empty($error)) {
|
||||||
if (!$error) {
|
header("Location: card.php?id=" . $object->id);
|
||||||
$result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', '');
|
exit;
|
||||||
if (!($result > 0)) {
|
|
||||||
$error++;
|
|
||||||
setEventMessages($paiement->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error) {
|
|
||||||
$db->commit();
|
|
||||||
} else {
|
|
||||||
$db->rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($error)) {
|
|
||||||
header("Location: card.php?id=" . $object->id);
|
$action = 'create';
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = 'create';
|
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||||
}
|
$result = $object->fetch($id);
|
||||||
|
$totalpaid = $object->getSommePaiement();
|
||||||
|
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
if (empty($totalpaid)) {
|
||||||
$result = $object->fetch($id);
|
$db->begin();
|
||||||
$totalpaid = $object->getSommePaiement();
|
|
||||||
|
|
||||||
if (empty($totalpaid)) {
|
$ret = $object->delete($user);
|
||||||
$db->begin();
|
if ($ret > 0) {
|
||||||
|
if ($object->fk_bank) {
|
||||||
$ret = $object->delete($user);
|
$accountline = new AccountLine($db);
|
||||||
if ($ret > 0) {
|
$result = $accountline->fetch($object->fk_bank);
|
||||||
if ($object->fk_bank) {
|
if ($result > 0) {
|
||||||
$accountline = new AccountLine($db);
|
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||||
$result = $accountline->fetch($object->fk_bank);
|
}
|
||||||
if ($result > 0) {
|
|
||||||
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php');
|
header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php');
|
||||||
exit;
|
exit;
|
||||||
|
} else {
|
||||||
|
$object->error = $accountline->error;
|
||||||
|
$db->rollback();
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$object->error = $accountline->error;
|
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
|
|
||||||
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
|
|
||||||
|
|
||||||
if (empty($amount)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
|
||||||
$action = 'edit';
|
|
||||||
} elseif (!is_numeric($amount)) {
|
|
||||||
setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
|
|
||||||
$action = 'create';
|
|
||||||
} else {
|
|
||||||
$result = $object->fetch($id);
|
|
||||||
|
|
||||||
$object->amount = $amount;
|
|
||||||
|
|
||||||
$result = $object->update($user);
|
|
||||||
if ($result <= 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Action clone object
|
if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
|
||||||
if ($action == 'confirm_clone' && $confirm != 'yes') {
|
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
|
||||||
$action = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer)) {
|
if (empty($amount)) {
|
||||||
$db->begin();
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
||||||
|
$action = 'edit';
|
||||||
$originalId = $id;
|
} elseif (!is_numeric($amount)) {
|
||||||
|
setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
|
||||||
$object->fetch($id);
|
$action = 'create';
|
||||||
|
|
||||||
if ($object->id > 0) {
|
|
||||||
$object->id = $object->ref = null;
|
|
||||||
$object->paye = 0;
|
|
||||||
|
|
||||||
if (GETPOST('amount', 'alphanohtml')) {
|
|
||||||
$object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GETPOST('clone_label', 'alphanohtml')) {
|
|
||||||
$object->label = GETPOST('clone_label', 'alphanohtml');
|
|
||||||
} else {
|
} else {
|
||||||
$object->label = $langs->trans("CopyOf").' '.$object->label;
|
$result = $object->fetch($id);
|
||||||
|
|
||||||
|
$object->amount = $amount;
|
||||||
|
|
||||||
|
$result = $object->update($user);
|
||||||
|
if ($result <= 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
|
|
||||||
if ($newdateperiod) {
|
|
||||||
$object->datev = $newdateperiod;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if ($object->check()) {
|
|
||||||
$id = $object->create($user);
|
|
||||||
if ($id > 0) {
|
|
||||||
$db->commit();
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$id = $originalId;
|
|
||||||
$db->rollback();
|
|
||||||
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
} else {
|
|
||||||
$db->rollback();
|
|
||||||
dol_print_error($db, $object->error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action clone object
|
||||||
|
if ($action == 'confirm_clone' && $confirm != 'yes') {
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer)) {
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$originalId = $id;
|
||||||
|
|
||||||
|
$object->fetch($id);
|
||||||
|
|
||||||
|
if ($object->id > 0) {
|
||||||
|
$object->id = $object->ref = null;
|
||||||
|
$object->paye = 0;
|
||||||
|
|
||||||
|
if (GETPOST('amount', 'alphanohtml')) {
|
||||||
|
$object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GETPOST('clone_label', 'alphanohtml')) {
|
||||||
|
$object->label = GETPOST('clone_label', 'alphanohtml');
|
||||||
|
} else {
|
||||||
|
$object->label = $langs->trans("CopyOf").' '.$object->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
|
||||||
|
if ($newdateperiod) {
|
||||||
|
$object->datev = $newdateperiod;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if ($object->check()) {
|
||||||
|
$id = $object->create($user);
|
||||||
|
if ($id > 0) {
|
||||||
|
$db->commit();
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$id = $originalId;
|
||||||
|
$db->rollback();
|
||||||
|
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
} else {
|
||||||
|
$db->rollback();
|
||||||
|
dol_print_error($db, $object->error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions to build doc
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -382,16 +387,7 @@ $title = $langs->trans("VAT")." - ".$langs->trans("Card");
|
|||||||
$help_url = '';
|
$help_url = '';
|
||||||
llxHeader('', $title, $help_url);
|
llxHeader('', $title, $help_url);
|
||||||
|
|
||||||
|
// Form to create a VAT
|
||||||
if ($id) {
|
|
||||||
$result = $object->fetch($id);
|
|
||||||
if ($result <= 0) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Form to enter VAT
|
|
||||||
if ($action == 'create') {
|
if ($action == 'create') {
|
||||||
print load_fiche_titre($langs->trans("VAT").' - '.$langs->trans("New"));
|
print load_fiche_titre($langs->trans("VAT").' - '.$langs->trans("New"));
|
||||||
|
|
||||||
@ -532,6 +528,8 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// View mode
|
// View mode
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
|
$formconfirm = '';
|
||||||
|
|
||||||
$head = vat_prepare_head($object);
|
$head = vat_prepare_head($object);
|
||||||
|
|
||||||
$totalpaid = $object->getSommePaiement();
|
$totalpaid = $object->getSommePaiement();
|
||||||
@ -546,25 +544,37 @@ if ($id > 0) {
|
|||||||
$formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
|
$formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
|
||||||
$formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100');
|
$formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100');
|
||||||
|
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'paid') {
|
if ($action == 'paid') {
|
||||||
$text = $langs->trans('ConfirmPayVAT');
|
$text = $langs->trans('ConfirmPayVAT');
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayVAT'), $text, "confirm_paid", '', '', 2);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayVAT'), $text, "confirm_paid", '', '', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
$text = $langs->trans('ConfirmDeleteVAT');
|
$text = $langs->trans('ConfirmDeleteVAT');
|
||||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVAT'), $text, 'confirm_delete', '', '', 2);
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVAT'), $text, 'confirm_delete', '', '', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
print "<form name=\"charge\" action=\"".$_SERVER["PHP_SELF"]."?id=$object->id&action=update\" method=\"post\">";
|
print '<form name="charge" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
}
|
||||||
|
// Call Hook formConfirm
|
||||||
|
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
||||||
|
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
$formconfirm .= $hookmanager->resPrint;
|
||||||
|
} elseif ($reshook > 0) {
|
||||||
|
$formconfirm = $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
print dol_get_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment');
|
print dol_get_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment', 0, '', '', 0, '', 1);
|
||||||
|
|
||||||
|
// Print form confirm
|
||||||
|
print $formconfirm;
|
||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
// Label of social contribution
|
// Label of social contribution
|
||||||
|
|||||||
@ -299,15 +299,13 @@ class Tva extends CommonObject
|
|||||||
* Load object in memory from database
|
* Load object in memory from database
|
||||||
*
|
*
|
||||||
* @param int $id id object
|
* @param int $id id object
|
||||||
* @param User $user User that load
|
* @param string $ref Ref of VAT (not used yet)
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetch($id, $user = null)
|
public function fetch($id, $ref = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
$sql .= " t.rowid,";
|
$sql .= " t.rowid,";
|
||||||
|
|
||||||
$sql .= " t.tms,";
|
$sql .= " t.tms,";
|
||||||
$sql .= " t.datep,";
|
$sql .= " t.datep,";
|
||||||
$sql .= " t.datev,";
|
$sql .= " t.datev,";
|
||||||
@ -320,12 +318,11 @@ class Tva extends CommonObject
|
|||||||
$sql .= " t.fk_user_creat,";
|
$sql .= " t.fk_user_creat,";
|
||||||
$sql .= " t.fk_user_modif,";
|
$sql .= " t.fk_user_modif,";
|
||||||
$sql .= " t.fk_account";
|
$sql .= " t.fk_account";
|
||||||
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||||
//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
|
|
||||||
$sql .= " WHERE t.rowid = ".((int) $id);
|
$sql .= " WHERE t.rowid = ".((int) $id);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if ($this->db->num_rows($resql)) {
|
if ($this->db->num_rows($resql)) {
|
||||||
|
|||||||
@ -11268,7 +11268,7 @@ function getElementProperties($element_type)
|
|||||||
|
|
||||||
$regs = array();
|
$regs = array();
|
||||||
|
|
||||||
$classfile = $classname = $classpath = $dir_output = '';
|
$classfile = $classname = $classpath = $subdir = $dir_output = '';
|
||||||
|
|
||||||
// Parse element/subelement
|
// Parse element/subelement
|
||||||
$module = $element_type;
|
$module = $element_type;
|
||||||
@ -11439,6 +11439,10 @@ function getElementProperties($element_type)
|
|||||||
} elseif ($element_type == 'chargesociales') {
|
} elseif ($element_type == 'chargesociales') {
|
||||||
$classpath = 'compta/sociales/class';
|
$classpath = 'compta/sociales/class';
|
||||||
$module = 'tax';
|
$module = 'tax';
|
||||||
|
} elseif ($element_type == 'tva') {
|
||||||
|
$classpath = 'compta/tva/class';
|
||||||
|
$module = 'tax';
|
||||||
|
$subdir = '/vat';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($classfile)) {
|
if (empty($classfile)) {
|
||||||
@ -11451,6 +11455,8 @@ function getElementProperties($element_type)
|
|||||||
$classpath = $module.'/class';
|
$classpath = $module.'/class';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//print 'getElementProperties subdir='.$subdir;
|
||||||
|
|
||||||
// Set dir_output
|
// Set dir_output
|
||||||
if ($module && isset($conf->$module)) { // The generic case
|
if ($module && isset($conf->$module)) { // The generic case
|
||||||
if (!empty($conf->$module->multidir_output[$conf->entity])) {
|
if (!empty($conf->$module->multidir_output[$conf->entity])) {
|
||||||
@ -11468,6 +11474,7 @@ function getElementProperties($element_type)
|
|||||||
} elseif ($element == 'invoice_supplier') {
|
} elseif ($element == 'invoice_supplier') {
|
||||||
$dir_output = $conf->fournisseur->facture->dir_output;
|
$dir_output = $conf->fournisseur->facture->dir_output;
|
||||||
}
|
}
|
||||||
|
$dir_output .= $subdir;
|
||||||
|
|
||||||
$element_properties = array(
|
$element_properties = array(
|
||||||
'module' => $module,
|
'module' => $module,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user