public function postPurchaseStore() { try { $input = Input::all(); $purchase = Purchase::find($input['purchase']); // Si no existe notaparcial y está pendiente es porque se está finalizando la remisión. if (!isset($input['notaparcial']) && $purchase->status == 'pendiente') { $pitems = PurchaseItem::where('purchase_id', '=', $input['purchase'])->get(); foreach ($pitems as $pitem) { self::saveInStockTable($input['branch_id'], $pitem->article->id, $pitem->amount); } /*Cambiar el status en la tabla purchase a finalizado*/ $purchase = Purchase::find($input['purchase']); $purchase->status = 'finalizado'; $purchase->save(); } $purchaseStore = new PurchaseStore(); $purchaseStore->purchase_id = $input['purchase']; $purchaseStore->user_id = Auth::user()->id; $purchaseStore->comments = $input['comments']; $purchaseStore->save(); return Redirect::to('purchases/items/' . $input['purchase']); } catch (Exception $e) { die('No se pudo aumentar el stock.<br />'); } }
function changeStatus($newStatus) { $_S =& new AppSettings(); $_EC = EComm::createObject(); if ($newStatus) { G::load($c, $this->cid, "appcategory"); // ha van expiration es ez az item meg sosem volt aktivalva, vagy ha restartExpOnModify van, // akkor az approve-tol indul az expiration $setStr = "status=1"; if ($this->expiration && ($this->expirationTime->isEmpty() || $c->restartExpOnModify)) { $this->expEmailSent = FALSE; $this->expirationTime = Date::add($this->expiration, Date_Day); $setStr .= ", expEmailSent=0, expirationTime='" . $this->expirationTime->getDbFormat() . "'"; } executeQuery("UPDATE @item SET {$setStr} WHERE id=#id#", $this->id); $c->increaseDirectItemNum(); // mailt kuldunk rola a tulajnak: G::load($n, Notification_adApproved, "notification"); if ($n->active) { $ownerEmail = $this->getEmailParams($params, FALSE); $n->send($ownerEmail, $params); } $this->sendNotificationsToSubscribedUsers($params); if ($_S->ecommerceEnabled() && !$_EC->isAdvancedModelEnabled()) { PurchaseItem::cleanUp($this); } } else { G::load($c, $this->cid, "appcategory"); $c->decreaseDirectItemNum(); } CacheManager::resetCache($this->cid); }