本文整理汇总了PHP中Purchase类的典型用法代码示例。如果您正苦于以下问题:PHP Purchase类的具体用法?PHP Purchase怎么用?PHP Purchase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Purchase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPurchase
/**
* Добавляем покупку
* @param Purchase $purchase
*/
public function addPurchase(Purchase $purchase)
{
$id = $purchase->getProduct()->getId();
if (isset($this->purchases[$id])) {
$this->purchases[$id]->setCount($this->purchases[$id]->getCount() + $purchase->getCount());
} else {
$this->purchases[$id] = $purchase;
}
$this->customer->addOrder($this);
}
示例2: orders
public function orders()
{
require_once '../app/models/Purchase.php';
$model = new Purchase();
$purchaseList = $model->generatePurchaseArray();
$view = new View('purchases/index');
$view->set_title('Your Orders');
$view->pass_data('purchaseList', $purchaseList);
$view->load_page();
}
示例3: store
/**
* Store a newly created stock in storage.
*
* @return Response
*/
public function store()
{
$stock = new Purchase();
$stock->item = Input::get('item');
$stock->selling_price = Input::get('selling_price');
$stock->price = Input::get('purchase_price');
$stock->quantity = Input::get('quantity');
$stock->status = Input::get('status');
$stock->account = Input::get('account');
$stock->save();
return Redirect::route('purchases.index');
}
示例4: delete
/**
* this method is needed to
* delete from a vendor list
*/
public function delete($id)
{
$article = Purchase::find_by_id($id);
if ($article->delete()) {
return true;
}
}
示例5: checkDuplicatePo
static function checkDuplicatePo($key)
{
$purchase = new Purchase($key);
//Search Duplicate
$records = fRecordSet::build('Purchase', array('po_number=' => $purchase->getPoNumber()));
if ($records->count() > 1) {
//Generate New PO
echo 'Duplicate PO';
$exploded = explode('/', $purchase->getPoNumber());
echo (int) $exploded[2] + 1;
$exploded[2] = sprintf("%03d", (int) $exploded[2] + 1);
$newPONumber = implode('/', $exploded);
$purchase->setPoNumber($newPONumber);
$purchase->store();
}
}
示例6: search
/**
* Search Licenses
*/
static function search($q = NULL, $param = NULL, $product_code = NULL)
{
$_tbl_licenses = License::getTableName();
$_tbl_licensesUses = LicensesUses::getTableName();
$_tbl_transactions = Transaction::getTableName();
$_tbl_purchases = Purchase::getTableName();
$_tbl_products = Product::getTableName();
$_tbl_plans = Plan::getTableName();
$_tbl_buyers = Buyer::getTableName();
$fields = array("{$_tbl_licenses}.*", DB::raw("COUNT({$_tbl_licensesUses}.id) AS totalUsed"), "{$_tbl_buyers}.first_name", "{$_tbl_buyers}.last_name", "{$_tbl_buyers}.email", "{$_tbl_products}.code", "{$_tbl_plans}.code AS plan_code", "{$_tbl_products}.api_key");
$licenses = DB::table($_tbl_licenses)->leftJoin($_tbl_licensesUses, "{$_tbl_licensesUses}.license_id", '=', "{$_tbl_licenses}.id")->join($_tbl_transactions, "{$_tbl_transactions}.id", '=', "{$_tbl_licenses}.transaction_id")->join($_tbl_plans, "{$_tbl_transactions}.plan_id", '=', "{$_tbl_plans}.id")->join($_tbl_purchases, "{$_tbl_purchases}.id", '=', "{$_tbl_transactions}.purchase_id")->join($_tbl_products, "{$_tbl_products}.id", '=', "{$_tbl_purchases}.product_id")->join($_tbl_buyers, "{$_tbl_buyers}.id", '=', "{$_tbl_purchases}.buyer_id")->select($fields)->groupBy("{$_tbl_licenses}.id");
$q = $q ? $q : Input::get('q');
$param = $param ? $param : Input::get('param');
if ($q) {
if ($param == "key") {
$licenses = $licenses->where("license_key", '=', $q);
}
if ($param == "email") {
$licenses = $licenses->where("email", '=', $q);
}
if ($product_code) {
$licenses = $licenses->where($_tbl_licenses . ".license_key", 'LIKE', strtoupper($product_code) . '-%');
}
}
return $licenses->orderBy($_tbl_licenses . '.created_at', 'DESC')->paginate(25);
}
示例7: createBaseFromData
protected static function createBaseFromData(\stdClass $data)
{
$object = new static();
$object->type = $data->type;
$object->uuid = $data->uuid;
$object->revisionHash = $data->hash;
$object->availableLanguageCodes = $data->languages;
$object->status = $data->status;
$object->contentProvider = ContentProvider::createFromData($data->content_provider);
if (isset($data->location)) {
$object->location = Location::createFromData($data->location);
}
if (isset($data->trigger_zones)) {
foreach ($data->trigger_zones as $triggerZoneData) {
$object->triggerZones[] = TriggerZone::createFromData($triggerZoneData);
}
}
if (isset($data->purchase)) {
$object->purchase = Purchase::createFromData($data->purchase);
}
if (isset($data->publisher)) {
$object->publisher = PublisherBase::createFromData($data->publisher);
}
if (isset($data->city)) {
$object->city = CityBase::createFromData($data->city);
}
if (isset($data->country)) {
$object->country = CountryBase::createFromData($data->country);
}
return $object;
}
示例8: purchase_edit
function purchase_edit()
{
$session = Session::getInstance();
if (!$session->checkLogin()) {
return false;
}
$purchase = new Purchase();
$purchase->id = isset($_POST['purchase']) ? $_POST['purchase'] : "";
$purchase->status = isset($_POST['status']) ? $_POST['status'] : "";
$purchase->update();
if (isset($_POST['payment']) && is_numeric($_POST['payment'])) {
$purchasePayment = new PurchasePayment();
$purchasePayment->purchaseid = isset($_POST['purchase']) ? $_POST['purchase'] : "";
$purchasePayment->amount = isset($_POST['payment']) ? $_POST['payment'] : "";
$purchasePayment->add();
}
}
示例9: show
/**
* Display customer profile
*
* @param $profile
* @return Response
*/
public function show($profile)
{
$p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
$page = Page::where('title', '=', 'faq-customer')->first();
$follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
$follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
$wall = new \Illuminate\Database\Eloquent\Collection();
$events = new \Illuminate\Database\Eloquent\Collection();
$comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
$hidden = unserialize(Cookie::get('hide'));
//dd( Cookie::get('hide') );
if (count($follow) > 0) {
foreach ($follow as $f) {
$s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
$e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
$wall = $wall->merge($s);
$events = $events->merge($e);
}
}
if (count($follow_hub) > 0) {
foreach ($follow_hub as $h) {
$hub = Hub::where('id', '=', $h->hub)->first();
if (!is_null($hub)) {
$artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
$artists_list = [];
$songs = [];
$events = [];
foreach ($artists as $a) {
$artists_list[] = $a->id;
}
if (count($artists_list) > 0) {
$songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
$events = ArtistEvent::whereIn('artist', $artists_list)->get();
}
$news = News::where('hub', '=', $hub->id)->take(3)->get();
$wall = $wall->merge($songs);
$events = $events->merge($events);
}
}
}
$purchased = Purchase::where('customer', '=', $p->id)->get();
foreach ($purchased as $pp) {
$song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
$download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
$song_purchased[0]->purchased = true;
if (isset($download)) {
$song_purchased[0]->link = $download->url;
}
$wall = $wall->merge($song_purchased);
}
$wall->sortByDesc('created_at');
if (!isset($news)) {
$news = null;
}
return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
}
示例10: create
public static function create(DB $db, Amount $denom, Purchase $p)
{
$prepared = $db->prepare('
INSERT INTO `bills` (
`entered_at`,
`denomination`,
`purchase_id`
) VALUES (
NOW(),
:denomination,
:purchase_id
)
');
$result = $prepared->execute(array(':denomination' => $denom->get(), ':purchase_id' => $p->getId()));
if ($result === false) {
throw new Exception("Unable to log bill.");
}
return self::load($db, $db->lastInsertId());
}
示例11: getDetail
public function getDetail()
{
//$id = \Input::get('id');
$input = \Input::all();
if ($input['type'] == 'sale') {
$detail = Sale::find($input['id']);
} else {
$detail = Purchase::find($input['id']);
}
return \Response::json($detail);
}
示例12: boot
public static function boot()
{
parent::boot();
static::deleted(function ($supplier) {
$supplier->purchases()->delete();
$purchases = Purchase::where('supplier_id', '=', $supplier->id);
dd($purchases);
$purchases->items()->detach();
$purchases->receivings()->delete();
$purchases->payments()->delete();
});
}
示例13: export_purchases
/**
* Delivers order export files to the browser
*
* @since 1.1
*
* @return void
**/
function export_purchases () {
if (!current_user_can('ecart_financials') || !current_user_can('ecart_export_orders')) exit();
if (!isset($_POST['settings']['purchaselog_columns'])) {
$Purchase = Purchase::exportcolumns();
$Purchased = Purchased::exportcolumns();
$_POST['settings']['purchaselog_columns'] =
array_keys(array_merge($Purchase,$Purchased));
$_POST['settings']['purchaselog_headers'] = "on";
}
$this->Settings->saveform();
$format = $this->Settings->get('purchaselog_format');
if (empty($format)) $format = 'tab';
switch ($format) {
case "csv": new PurchasesCSVExport(); break;
case "xls": new PurchasesXLSExport(); break;
case "iif": new PurchasesIIFExport(); break;
default: new PurchasesTabExport();
}
exit();
}
示例14: updatePurchase
public function updatePurchase($Id, &$amount)
{
$model = Purchase::model()->findByPk($Id);
$amount = $model->amount;
$ttlamount = 0;
foreach($model->purchaseproducts as $product)
{
$ttlamount += $product->amount;
}
$model->amount= $ttlamount;
$status = $model->save();
if($status)
{
$amount = $ttlamount;
}
return $status;
}
示例15: executeGeneratePurchase
public function executeGeneratePurchase(sfWebRequest $request)
{
$invoice = Doctrine_Query::create()->from('Invoice i')->where('i.id = ' . $request->getParameter('id'))->fetchOne();
//create purchase
$purchase = new Purchase();
$purchase->setDate(date("Y-m-d"));
$purchase->setPono(date('h:i:s a'));
$purchase->save();
//create purchase details
foreach ($invoice->getInvoicedetail() as $invdetail) {
$purchdetail = new PurchaseDetail();
$purchdetail->setPurchaseId($purchase->getId());
$purchdetail->setProductId($invdetail->getProductId());
$purchdetail->setDescription($invdetail->getProduct()->getName());
$purchdetail->setQty($invdetail->getQty());
$purchdetail->setPrice(0);
$purchdetail->setTotal(0);
$purchdetail->setUnittotal(0);
$purchdetail->save();
$purchdetail->updateStockentry();
}
$this->redirect("purchase/view?id=" . $purchase->getId());
}