本文整理匯總了PHP中Invitation::scope方法的典型用法代碼示例。如果您正苦於以下問題:PHP Invitation::scope方法的具體用法?PHP Invitation::scope怎麽用?PHP Invitation::scope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Invitation
的用法示例。
在下文中一共展示了Invitation::scope方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
private function save($publicId = null)
{
$action = Input::get('action');
$entityType = Input::get('entityType');
if (in_array($action, ['archive', 'delete', 'mark', 'restore'])) {
return InvoiceController::bulk($entityType);
}
$input = json_decode(Input::get('data'));
$invoice = $input->invoice;
if ($errors = $this->invoiceRepo->getErrors($invoice)) {
Session::flash('error', trans('texts.invoice_error'));
return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
} else {
$this->taxRateRepo->save($input->tax_rates);
$clientData = (array) $invoice->client;
$client = $this->clientRepo->save($invoice->client->public_id, $clientData);
$invoiceData = (array) $invoice;
$invoiceData['client_id'] = $client->id;
$invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
$account = Auth::user()->account;
if ($account->invoice_taxes != $input->invoice_taxes || $account->invoice_item_taxes != $input->invoice_item_taxes || $account->invoice_design_id != $input->invoice->invoice_design_id) {
$account->invoice_taxes = $input->invoice_taxes;
$account->invoice_item_taxes = $input->invoice_item_taxes;
$account->invoice_design_id = $input->invoice->invoice_design_id;
$account->save();
}
$client->load('contacts');
$sendInvoiceIds = [];
foreach ($client->contacts as $contact) {
if ($contact->send_invoice || count($client->contacts) == 1) {
$sendInvoiceIds[] = $contact->id;
}
}
foreach ($client->contacts as $contact) {
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
$invitation = Invitation::createNew();
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $contact->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
} else {
if (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
$invitation->delete();
}
}
}
$message = trans($publicId ? "texts.updated_{$entityType}" : "texts.created_{$entityType}");
if ($input->invoice->client->public_id == '-1') {
$message = $message . ' ' . trans('texts.and_created_client');
$url = URL::to('clients/' . $client->public_id);
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
}
if ($action == 'clone') {
return $this->cloneInvoice($publicId);
} else {
if ($action == 'convert') {
return $this->convertQuote($publicId);
} else {
if ($action == 'email') {
if (Auth::user()->confirmed && !Auth::user()->isDemo()) {
$message = trans("texts.emailed_{$entityType}");
$this->mailer->sendInvoice($invoice);
Session::flash('message', $message);
} else {
$errorMessage = trans(Auth::user()->registered ? 'texts.confirmation_required' : 'texts.registration_required');
Session::flash('error', $errorMessage);
Session::flash('message', $message);
}
} else {
Session::flash('message', $message);
}
}
}
$url = "{$entityType}s/" . $invoice->public_id . '/edit';
return Redirect::to($url);
}
}
示例2: save
private function save($publicId = null)
{
$action = Input::get('action');
$entityType = Input::get('entityType');
if ($action == 'archive' || $action == 'delete' || $action == 'mark') {
return InvoiceController::bulk($entityType);
}
$input = json_decode(Input::get('data'));
$invoice = $input->invoice;
if (Utils::isAdmin()) {
$branch_id = $input->invoice->branch_id;
$branch = Branch::where('account_id', '=', Auth::user()->account_id)->where('public_id', $branch_id)->first();
// $branch = DB::table('branches')->where('id',$branch_id)->first();
} else {
$branch = Auth::user()->branch;
$branch_id = $branch->id;
$branch = DB::table('branches')->where('id', $branch_id)->first();
}
$today = new DateTime('now');
$today = $today->format('Y-m-d');
$datelimit = DateTime::createFromFormat('Y-m-d', $branch->deadline);
$datelimit = $datelimit->format('Y-m-d');
$valoresPrimera = explode("-", $datelimit);
$valoresSegunda = explode("-", $today);
$diaPrimera = $valoresPrimera[2];
$mesPrimera = $valoresPrimera[1];
$anyoPrimera = $valoresPrimera[0];
$diaSegunda = $valoresSegunda[2];
$mesSegunda = $valoresSegunda[1];
$anyoSegunda = $valoresSegunda[0];
$a = gregoriantojd($mesPrimera, $diaPrimera, $anyoPrimera);
$b = gregoriantojd($mesSegunda, $diaSegunda, $anyoSegunda);
$errorS = "Expiró la fecha límite de " . $branch->name;
if ($a - $b < 0) {
Session::flash('error', $errorS);
return Redirect::to("{$entityType}s/create")->withInput();
} else {
$last_invoice = Invoice::where('account_id', '=', Auth::user()->account_id)->first();
if ($last_invoice) {
$yesterday = $last_invoice->invoice_date;
$today = date("Y-m-d", strtotime($invoice->invoice_date));
$errorD = "La fecha de la factura es incorrecta";
$yesterday = new DateTime($yesterday);
$today = new DateTime($today);
if ($yesterday > $today) {
Session::flash('error', $errorD);
return Redirect::to("{$entityType}s/create")->withInput();
}
}
if ($errors = $this->invoiceRepo->getErrors($invoice)) {
Session::flash('error', trans('texts.invoice_error'));
return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
} else {
$this->taxRateRepo->save($input->tax_rates);
$clientData = (array) $invoice->client;
$clientData['branch'] = $branch->id;
$client = $this->clientRepo->save($invoice->client->public_id, $clientData);
$invoiceData = (array) $invoice;
$invoiceData['branch_id'] = $branch->id;
$invoiceData['client_id'] = $client->id;
$invoiceData['client_nit'] = $client->nit;
$invoiceData['client_name'] = $client->name;
$invoiceData['action'] = $action;
$invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
$account = Auth::user()->account;
// if ($account->invoice_taxes != $input->invoice_taxes
// || $account->invoice_item_taxes != $input->invoice_item_taxes
// || $account->invoice_design_id != $input->invoice->invoice_design_id)
// {
// $account->invoice_taxes = $input->invoice_taxes;
// $account->invoice_item_taxes = $input->invoice_item_taxes;
// $account->invoice_design_id = $input->invoice->invoice_design_id;
// $account->save();
// }
$client->load('contacts');
$sendInvoiceIds = [];
foreach ($client->contacts as $contact) {
if ($contact->send_invoice || count($client->contacts) == 1) {
$sendInvoiceIds[] = $contact->id;
}
}
foreach ($client->contacts as $contact) {
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
$invitation = Invitation::createNew();
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $contact->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
} else {
if (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
$invitation->delete();
}
}
}
$invoice_date = date("d/m/Y", strtotime($invoice->invoice_date));
require_once app_path() . '/includes/BarcodeQR.php';
// $ice = $invoice->amount-$invoice->fiscal;
$desc = $invoice->subtotal - $invoice->amount;
$subtotal = number_format($invoice->subtotal, 2, '.', '');
//.........這裏部分代碼省略.........
示例3: save
private function save($publicId = null)
{
$action = Input::get('action');
if ($action == 'archive' || $action == 'delete') {
return InvoiceController::bulk();
}
$input = json_decode(Input::get('data'));
$invoice = $input->invoice;
// if ($errors = $this->invoiceRepo->getErrors($invoice))
// {
// Session::flash('error', trans('texts.invoice_error'));
// return Redirect::to('invoices/create')
// ->withInput()->withErrors($errors);
// }
// else
// {
$this->taxRateRepo->save($input->tax_rates);
$clientData = (array) $invoice->client;
$client = $this->clientRepo->save($invoice->client->public_id, $clientData);
$invoiceData = (array) $invoice;
$invoiceData['client_id'] = $client->id;
$invoiceData['nit'] = $client->nit;
$invoiceData['name'] = $client->name;
$invoice = $this->invoiceRepo->save($publicId, $invoiceData);
$account = Auth::user()->account;
if ($account->invoice_taxes != $input->invoice_taxes || $account->invoice_item_taxes != $input->invoice_item_taxes || $account->invoice_design_id != $input->invoice->invoice_design_id) {
$account->invoice_taxes = $input->invoice_taxes;
$account->invoice_item_taxes = $input->invoice_item_taxes;
$account->invoice_design_id = $input->invoice->invoice_design_id;
$account->save();
}
$client->load('contacts');
$sendInvoiceIds = [];
foreach ($client->contacts as $contact) {
if ($contact->send_invoice || count($client->contacts) == 1) {
$sendInvoiceIds[] = $contact->id;
}
}
foreach ($client->contacts as $contact) {
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
$invitation = Invitation::createNew();
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $contact->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
} else {
if (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
$invitation->delete();
}
}
}
$branch = Auth::user()->branch;
$invoice_dateCC = date("Ymd", strtotime($invoice->invoice_date));
$invoice_date = date("d/m/Y", strtotime($invoice->invoice_date));
$invoice_date_limitCC = date("d/m/Y", strtotime($branch->deadline));
require_once app_path() . '/includes/control_code.php';
$cod_control = codigoControl($invoice->invoice_number, $client->nit, $invoice_dateCC, $invoice->amount, $branch->number_autho, $branch->key_dosage);
$invoice->control_code = $cod_control;
$invoice->number_autho = $branch->number_autho;
$invoice->deadline = $branch->deadline;
$invoice->key_dosage = $branch->key_dosage;
$invoice->activity_pri = $branch->activity_pri;
$invoice->activity_sec1 = $branch->activity_sec1;
$invoice->law = $branch->law;
$invoice->branch = $branch->name;
$invoice->address1 = $branch->address1;
$invoice->address2 = $branch->address2;
$invoice->work_phone = $branch->postal_code;
$invoice->city = $branch->city;
$invoice->state = $branch->state;
$invoice->save();
require_once app_path() . '/includes/BarcodeQR.php';
$ice = $invoice->amount - $invoice->fiscal;
$desc = $invoice->subtotal - $invoice->amount;
$amount = number_format($invoice->amount, 2, '.', '');
$fiscal = number_format($invoice->fiscal, 2, '.', '');
$icef = number_format($ice, 2, '.', '');
$descf = number_format($desc, 2, '.', '');
if ($icef == "0.00") {
$icef = 0;
}
if ($descf == "0.00") {
$descf = 0;
}
$qr = new BarcodeQR();
$datosqr = '1006909025|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice_date . '|' . $amount . '|' . $fiscal . '|' . $invoice->control_code . '|' . $invoice->nit . '|' . $icef . '|0|0|' . $descf;
$qr->text($datosqr);
$qr->draw(150, 'qr/' . $account->account_key . '_' . $invoice->invoice_number . '.png');
$input_file = 'qr/' . $account->account_key . '_' . $invoice->invoice_number . '.png';
$output_file = 'qr/' . $account->account_key . '_' . $invoice->invoice_number . '.jpg';
$inputqr = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $inputqr, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
$invoice->qr = HTML::image_data('qr/' . $account->account_key . '_' . $invoice->invoice_number . '.jpg');
$invoice->save();
//.........這裏部分代碼省略.........