本文整理匯總了PHP中Facture::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::delete方法的具體用法?PHP Facture::delete怎麽用?PHP Facture::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facture
的用法示例。
在下文中一共展示了Facture::delete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: delete
/**
* Delete invoice
*
* @param int $id Invoice ID
* @return type
*
* @url DELETE invoice/{id}
*/
function delete($id)
{
if (!DolibarrApiAccess::$user->rights->facture->supprimer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Facture not found');
}
if (!DolibarrApi::_checkAccessToResource('facture', $this->facture->id)) {
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
}
if (!$this->invoice->delete($id)) {
throw new RestException(500);
}
return array('success' => array('code' => 200, 'message' => 'Facture deleted'));
}
示例2: testFactureDelete
/**
* testFactureDelete
*
* @param int $id Id of invoice
* @return int
*
* @depends testFactureOther
* The depends says test is run only if previous is ok
*/
public function testFactureDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Facture($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
示例3: _createAvoir
function _createAvoir(&$PDOdb, &$db, &$user, &$conf, &$langs)
{
dol_include_once('/compta/facture/class/facture.class.php');
dol_include_once('/core/class/discount.class.php');
$sql = _getSql2();
$PDOdb->Execute($sql);
$TFacnumberFetchError = array();
$TFacnumberCreateError = array();
$TDiscountCreateError = array();
$nbValidate = 0;
while ($row = $PDOdb->Get_line()) {
$fk_soc = $row->fk_soc;
$facnumber = $row->facnumber;
$factureImpayee = new Facture($db);
if ($factureImpayee->fetch(null, $facnumber) <= 0) {
$TFacnumberFetchError[] = $facnumber;
continue;
}
$dateinvoice = dol_mktime(12, 0, 0, date('m'), date('d'), date('Y'));
$facture = new Facture($db);
$facture->socid = $fk_soc;
$facture->fk_facture_source = $factureImpayee->id;
$facture->type = Facture::TYPE_CREDIT_NOTE;
$facture->date = $dateinvoice;
if ($facture->create($user) <= 0) {
$TFacnumberCreateError[] = $facnumber;
continue;
}
foreach ($factureImpayee->lines as $line) {
$line->fk_facture = $facture->id;
$line->subprice = -$line->subprice;
// invert price for object
$line->pa_ht = -$line->pa_ht;
$line->total_ht = -$line->total_ht;
$line->total_tva = -$line->total_tva;
$line->total_ttc = -$line->total_ttc;
$line->total_localtax1 = -$line->total_localtax1;
$line->total_localtax2 = -$line->total_localtax2;
$line->insert();
$facture->lines[] = $line;
// insert new line in current object
}
$facture->update_price(1);
$facture->validate($user);
$discountcheck = new DiscountAbsolute($db);
$result = $discountcheck->fetch(0, $facture->id);
if (!empty($discountcheck->id)) {
//can't convert
$facture->delete();
continue;
}
$i = 0;
$amount_ht = $amount_tva = $amount_ttc = array();
foreach ($facture->lines as $line) {
if ($line->total_ht != 0) {
// no need to create discount if amount is null
$amount_ht[$line->tva_tx] += $line->total_ht;
$amount_tva[$line->tva_tx] += $line->total_tva;
$amount_ttc[$line->tva_tx] += $line->total_ttc;
$i++;
}
}
// Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db);
$discount->description = '(CREDIT_NOTE)';
$discount->tva_tx = abs($facture->total_ttc);
$discount->fk_soc = $facture->socid;
$discount->fk_facture_source = $facture->id;
foreach ($amount_ht as $tva_tx => $xxx) {
$discount->amount_ht = abs($amount_ht[$tva_tx]);
$discount->amount_tva = abs($amount_tva[$tva_tx]);
$discount->amount_ttc = abs($amount_ttc[$tva_tx]);
$discount->tva_tx = abs($tva_tx);
$result = $discount->create($user);
if ($result < 0) {
$TDiscountCreateError[] = $facnumber;
$error++;
break;
}
$result = $facture->set_paid($user);
$result = $discount->link_to_invoice(0, $factureImpayee->id);
$r = $factureImpayee->set_paid($user);
}
/******/
$nbValidate++;
}
if ($nbValidate) {
setEventMessages($langs->trans('sendinvoicetoadherentAvoirValidate', $nbValidate), null);
}
if (count($TFacnumberFetchError) > 0) {
setEventMessages($langs->trans('sendinvoicetoadherentErrorFetchFacture', count($TFacnumberFetchError)), null, 'errors');
}
if (count($TFacnumberCreateError) > 0) {
setEventMessages($langs->trans('sendinvoicetoadherentErrorCreateAvoir', count($TFacnumberCreateError)), null, 'errors');
}
$_SESSION['SENDTOINVOICETOADHERENT_TFETCHERROR'] = $TFacnumberFetchError;
$_SESSION['SENDTOINVOICETOADHERENT_TCREATEERROR'] = $TFacnumberCreateError;
header('Location: ' . dol_buildpath('/sendinvoicetoadherent/sendinvoicetoadherent.php?action=listAvoir', 2));
exit;
}
開發者ID:ATM-Consulting,項目名稱:dolibarr_module_sendinvoicetoadherent,代碼行數:100,代碼來源:sendinvoicetoadherent.php