本文整理匯總了PHP中Facture::getIdReplacingInvoice方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::getIdReplacingInvoice方法的具體用法?PHP Facture::getIdReplacingInvoice怎麽用?PHP Facture::getIdReplacingInvoice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facture
的用法示例。
在下文中一共展示了Facture::getIdReplacingInvoice方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
/**
* Tag invoice as validated + call trigger BILL_VALIDATE
* Object must have lines loaded with fetch_lines
*
* @param User $user Object user that validate
* @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$now = dol_now();
$error = 0;
dol_syslog(get_class($this) . '::validate user=' . $user->id . ', force_number=' . $force_number . ', idwarehouse=' . $idwarehouse);
// Check parameters
if (!$this->brouillon) {
dol_syslog(get_class($this) . "::validate no draft status", LOG_WARNING);
return 0;
}
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer) || !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate)) {
$this->error = 'Permission denied';
dol_syslog(get_class($this) . "::validate " . $this->error, LOG_ERR);
return -1;
}
$this->db->begin();
$this->fetch_thirdparty();
$this->fetch_lines();
// Check parameters
if ($this->type == self::TYPE_REPLACEMENT) {
// Controle que facture source connue
if ($this->fk_facture_source <= 0) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement"));
$this->db->rollback();
return -10;
}
// Charge la facture source a remplacer
$facreplaced = new Facture($this->db);
$result = $facreplaced->fetch($this->fk_facture_source);
if ($result <= 0) {
$this->error = $langs->trans("ErrorBadInvoice");
$this->db->rollback();
return -11;
}
// Controle que facture source non deja remplacee par une autre
$idreplacement = $facreplaced->getIdReplacingInvoice('validated');
if ($idreplacement && $idreplacement != $this->id) {
$facreplacement = new Facture($this->db);
$facreplacement->fetch($idreplacement);
$this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref);
$this->db->rollback();
return -12;
}
$result = $facreplaced->set_canceled($user, 'replaced', '');
if ($result < 0) {
$this->error = $facreplaced->error;
$this->db->rollback();
return -13;
}
}
// Define new ref
if ($force_number) {
$num = $force_number;
} else {
if (preg_match('/^[\\(]?PROV/i', $this->ref) || empty($this->ref)) {
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
$this->date = dol_now();
$this->date_lim_reglement = $this->calculate_date_lim_reglement();
}
$num = $this->getNextNumRef($this->client);
} else {
$num = $this->ref;
}
}
$this->newref = $num;
if ($num) {
$this->update_price(1);
// Validate
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture';
$sql .= " SET facnumber='" . $num . "', fk_statut = " . self::STATUS_VALIDATED . ", fk_user_valid = " . $user->id . ", date_valid = '" . $this->db->idate($now) . "'";
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
$sql .= ", datef='" . $this->db->idate($this->date) . "'";
$sql .= ", date_lim_reglement='" . $this->db->idate($this->date_lim_reglement) . "'";
}
$sql .= ' WHERE rowid = ' . $this->id;
dol_syslog(get_class($this) . "::validate", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
dol_print_error($this->db);
$error++;
}
// On verifie si la facture etait une provisoire
if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
// La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
}
if (!$error) {
// Define third party as a customer
$result = $this->client->set_as_client();
//.........這裏部分代碼省略.........
示例2: validate
/**
* Tag invoice as validated + call trigger BILL_VALIDATE
* Object must have lines loaded with fetch_lines
*
* @param User $user Object user that validate
* @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease
* @return int <0 if KO, >0 if OK
*/
function validate($user, $force_number = '', $idwarehouse = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
$now = dol_now();
$error = 0;
dol_syslog(get_class($this) . '::validate user=' . $user->id . ', force_number=' . $force_number . ', idwarehouse=' . $idwarehouse, LOG_WARNING);
// Check parameters
if (!$this->brouillon) {
dol_syslog(get_class($this) . "::validate no draft status", LOG_WARNING);
return 0;
}
if (!$user->rights->facture->valider) {
$this->error = 'Permission denied';
dol_syslog(get_class($this) . "::validate " . $this->error, LOG_ERR);
return -1;
}
$this->db->begin();
$this->fetch_thirdparty();
$this->fetch_lines();
// Check parameters
if ($this->type == 1) {
// Controle que facture source connue
if ($this->fk_facture_source <= 0) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement"));
$this->db->rollback();
return -10;
}
// Charge la facture source a remplacer
$facreplaced = new Facture($this->db);
$result = $facreplaced->fetch($this->fk_facture_source);
if ($result <= 0) {
$this->error = $langs->trans("ErrorBadInvoice");
$this->db->rollback();
return -11;
}
// Controle que facture source non deja remplacee par une autre
$idreplacement = $facreplaced->getIdReplacingInvoice('validated');
if ($idreplacement && $idreplacement != $this->id) {
$facreplacement = new Facture($this->db);
$facreplacement->fetch($idreplacement);
$this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref);
$this->db->rollback();
return -12;
}
$result = $facreplaced->set_canceled($user, 'replaced', '');
if ($result < 0) {
$this->error = $facreplaced->error;
$this->db->rollback();
return -13;
}
}
// Define new ref
if ($force_number) {
$num = $force_number;
} else {
if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
$this->date = dol_now();
$this->date_lim_reglement = $this->calculate_date_lim_reglement();
}
$num = $this->getNextNumRef($this->client);
} else {
$num = $this->ref;
}
}
if ($num) {
$this->update_price(1);
// Validate
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture';
$sql .= " SET facnumber='" . $num . "', fk_statut = 1, fk_user_valid = " . $user->id . ", date_valid = '" . $this->db->idate($now) . "'";
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
$sql .= ', datef=' . $this->db->idate($this->date);
$sql .= ', date_lim_reglement=' . $this->db->idate($this->date_lim_reglement);
}
$sql .= ' WHERE rowid = ' . $this->id;
dol_syslog(get_class($this) . "::validate sql=" . $sql);
$resql = $this->db->query($sql);
if (!$resql) {
dol_syslog(get_class($this) . "::validate Echec update - 10 - sql=" . $sql, LOG_ERR);
dol_print_error($this->db);
$error++;
}
// On verifie si la facture etait une provisoire
if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
// La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
}
if (!$error) {
// Define third party as a customer
$result = $this->client->set_as_client();
// Si active on decremente le produit principal et ses composants a la validation de facture
//.........這裏部分代碼省略.........