本文整理汇总了PHP中Model_Order::make_new_order方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Order::make_new_order方法的具体用法?PHP Model_Order::make_new_order怎么用?PHP Model_Order::make_new_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Order
的用法示例。
在下文中一共展示了Model_Order::make_new_order方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_update
//.........这里部分代码省略.........
}
}
if ($filename = FALSE) {
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $form->id_ad)));
}
}
try {
// if user changes category, do payment first
// moderation 2 -> payment on, moderation 5 -> payment with moderation
// data['cat'] -> category selected , last_known_ad->id_category -> obj of current ad (before save)
$moderation = core::config('general.moderation');
$last_known_ad = $obj_ad->where('id_ad', '=', $this->request->param('id'))->limit(1)->find();
if ($moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::PAYMENT_MODERATION) {
// PAYMENT METHOD ACTIVE
$payment_order = new Model_Order();
$advert_have_order = $payment_order->where('id_ad', '=', $this->request->param('id'));
if ($data['cat'] == $last_known_ad->id_category) {
// check if he payed when ad was created (is successful),
// if not give him alert that he didn't payed, and ad will not be published until he do
$cat_check = $cat->where('id_category', '=', $last_known_ad->id_category)->limit(1)->find();
// current category
$advert_have_order->and_where('description', '=', $cat_check->seoname)->limit(1)->find();
if ($advert_have_order->loaded()) {
if ($advert_have_order->status != Model_Order::STATUS_PAID) {
// order is not payed,
$form->status = 0;
Alert::set(Alert::INFO, __('Advertisement is updated, but it won\'t be published until payment is done.'));
} else {
if ($moderation == Model_Ad::PAYMENT_ON) {
$form->status = 1;
Alert::set(Alert::SUCCESS, __('Advertisement is updated!'));
} else {
if ($moderation == 5) {
Alert::set(Alert::SUCCESS, __('Advertisement is updated!'));
}
}
}
}
$form->save();
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $form->id_ad)));
} else {
// user have pending order with new category(possible that he previously tried to do the same action)
$cat_check = $cat->where('id_category', '=', $data['cat'])->limit(1)->find();
// newly selected category
$advert_have_order->and_where('description', '=', $cat_check->seoname)->limit(1)->find();
if ($advert_have_order->loaded()) {
// sanity check -> we don't want to charge him twice for same category
if ($advert_have_order->status != Model_Order::STATUS_PAID) {
$this->request->redirect(Route::url('default', array('controller' => 'payment_paypal', 'action' => 'form', 'id' => $advert_have_order->id_order)));
} else {
if ($moderation == Model_Ad::PAYMENT_ON) {
$form->status = 1;
Alert::set(Alert::SUCCESS, __('Advertisement is updated!'));
} else {
if ($moderation == Model_Ad::PAYMENT_MODERATION) {
Alert::set(Alert::SUCCESS, __('Advertisement is updated!'));
}
}
}
$form->save();
} else {
$order_id = $payment_order->make_new_order($data, Auth::instance()->get_user()->id_user, $form->seotitle);
if ($order_id == NULL) {
if ($moderation == Model_Ad::PAYMENT_ON) {
// publish
$form->status = 1;
}
} else {
// redirect to payment
$this->request->redirect(Route::url('default', array('controller' => 'payment_paypal', 'action' => 'form', 'id' => $order_id)));
// @TODO - check route
}
$form->save();
}
}
}
// save ad
$form->status = $last_known_ad->status;
$form->save();
Alert::set(Alert::SUCCESS, __('Advertisement is updated'));
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $form->id_ad)));
} catch (Exception $e) {
//throw 500
throw new HTTP_Exception_500($e->getMessage());
}
}
} else {
Alert::set(Alert::ERROR, __('You dont have permission to access this link'));
$this->request->redirect(Route::url('default'));
}
// QR!!!
$qr = new Qr($this->request->param('id'));
$qr->reset();
$f = $qr->qr();
$qr->calendar();
// $qr->map();
$qr->website();
$qr->contact();
Alert::set(Alert::SUCCESS, "Wrote " . print_r($f, true));
}
示例2: save_new_ad
//.........这里部分代码省略.........
$url_ql = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $new_ad->id_ad), TRUE);
$ret = $user->email('ads.notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $new_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
// email to notify user of creating, but it is in moderation currently
} elseif ($moderation == Model_Ad::POST_DIRECTLY) {
$edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $new_ad->id_ad;
$delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $new_ad->id_ad;
$url_cont = $user->ql('contact', array(), TRUE);
$url_ad = $user->ql('ad', array('category' => $data['cat'], 'seotitle' => $seotitle), TRUE);
$ret = $user->email('ads.user_check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $new_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
}
// new ad notification email to admin (notify_email), if set to TRUE
if (core::config('email.new_ad_notify')) {
$url_ad = $user->ql('ad', array('category' => $data['cat'], 'seotitle' => $seotitle), TRUE);
$replace = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $new_ad->title);
Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads.to_admin', $replace);
}
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
// IMAGE UPLOAD
// in case something wrong happens user is redirected to edit advert.
$filename = NULL;
$counter = 0;
for ($i = 0; $i < core::config("advertisement.num_images"); $i++) {
$counter++;
if (isset($_FILES['image' . $i])) {
$fh = fopen('/tmp/grisha.log', 'a');
$img_files = $_FILES['image' . $i];
if (isset($_REQUEST['wb_base64'])) {
fwrite($fh, "Base64 is true\n");
$old_name = $_FILES['image' . $i]['tmp_name'];
$new_name = $old_name . "_decoded";
$img_files['tmp_name'] = $_FILES['image' . $i]['tmp_name'] = $new_name;
$img_files['old_name'] = $old_name;
copy($old_name, '/tmp/grisha/' . basename($old_name));
fwrite($fh, "Decoding from {$old_name} to {$new_name}\n");
$encoded = file_get_contents($old_name);
$decoded = base64_decode($encoded);
$result = file_put_contents($new_name, $decoded);
$img_files['size'] = $_FILES['image' . $i]['size'] = filesize($new_name);
copy($new_name, '/tmp/grisha/' . basename($new_name));
fwrite($fh, "Wrote: " . $result . " to {$new_name}");
fwrite($fh, "{$_FILES}: " . print_r($_FILES, true));
fwrite($fh, "{$img_files}: " . print_r($img_files, true));
fclose($fh);
}
$filename = $new_ad->save_image($img_files, $new_ad->id_ad, $created, $new_ad->seotitle, $counter);
}
if ($filename) {
$new_ad->has_images = 1;
try {
$new_ad->save();
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
}
if ($filename = FALSE) {
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $new_ad->id_ad)));
}
}
// PAYMENT METHOD ACTIVE (and other alerts)
if ($moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::PAYMENT_MODERATION) {
$payment_order = new Model_Order();
$order_id = $payment_order->make_new_order($data, $user, $seotitle);
if ($order_id == NULL) {
if ($moderation == Model_Ad::PAYMENT_ON) {
$new_ad->status = 1;
$new_ad->published = Date::unix2mysql(time());
try {
$new_ad->save();
Alert::set(Alert::SUCCESS, __('Advertisement is published. Congratulations!'));
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
}
if ($moderation == Model_Ad::PAYMENT_MODERATION) {
Alert::set(Alert::SUCCESS, __('Advertisement is created but needs to be validated first before it is published.'));
}
$this->request->redirect(Route::url('default'));
}
// redirect to payment
$this->request->redirect(Route::url('default', array('controller' => 'payment_paypal', 'action' => 'form', 'id' => $order_id)));
// @TODO - check route
} elseif ($moderation == Model_Ad::EMAIL_MODERATION or $moderation == Model_Ad::EMAIL_CONFIRMATION) {
Alert::set(Alert::INFO, __('Advertisement is posted but first you need to activate. Please check your email!'));
$this->request->redirect(Route::url('default'));
} elseif ($moderation == Model_Ad::MODERATION_ON) {
Alert::set(Alert::INFO, __('Advertisement is received, but first administrator needs to validate. Thank you for being patient!'));
$this->request->redirect(Route::url('default'));
} else {
Model_Subscribe::find_subscribers($data, floatval(str_replace(',', '.', $data['price'])), $seotitle, $email);
Alert::set(Alert::SUCCESS, __('Advertisement is posted. Congratulations!'));
$this->request->redirect(Route::url('default'));
}
} else {
Alert::set(Alert::ALERT, __('Captcha is not correct'));
}
}
//is post
}