Esempio n. 1
0
 public function update()
 {
     $orderEntity = false;
     if ($this->isPost()) {
         $tableName = zbase_entity('custom_orders')->getTable();
         $name = zbase_request_input('name', false);
         $orderId = zbase_request_input('order_id', false);
         $amount = zbase_request_input('amount', false);
         $validators = ['name' => 'required', 'amount' => 'required', 'order_id' => 'required|exists:' . $tableName . ',order_id,name,' . $name . ',total,' . number_format($amount, 2) . ',status,1', 'date' => 'required|date_format:Y-m-d|before:' . zbase_date_now()->addDay(), 'payment_center' => 'required', 'file' => 'required|image'];
         $messages = ['order_id.exists' => 'Order ID, Name and Amount don\'t match.', 'amount.required' => 'Enter the amount that you deposited or paid.', 'file.required' => 'Kindly upload your deposit or payment slip.', 'file.image' => 'The file you uploaded is not an image.'];
         $this->validate(zbase_request(), $validators, $messages);
         $folder = zbase_storage_path() . '/zivsluck/order/receipts/';
         $newFilename = zbase_file_name_from_file($_FILES['file']['name'], $orderId, true);
         $newFilename = zbase_file_upload_image('file', $folder, $newFilename, 'png', [280, null]);
         if (file_exists($newFilename)) {
             $orderEntity = zbase_entity('custom_orders')->repository()->byId($orderId);
             $orderEntity->status = 2;
             $orderEntity->payment_merchant = zbase_request_input('payment_center', null);
             $orderEntity->paid_date_at = zbase_request_input('date', null);
             $orderEntity->payment_tracking_number = zbase_request_input('payment_tracking', null);
             $orderEntity->save();
             $orderEntity->sendPaymentReceiptToShane();
         }
     }
     zbase_view_pagetitle_set('Update Order');
     return $this->view(zbase_view_file('order.update'), compact('orderEntity'));
 }
Esempio n. 2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function userCreate(array $data)
 {
     $user = ['status' => $this->defaultNewUserStatus(), 'username' => strtolower(!empty($data['username']) ? $data['username'] : null), 'name' => !empty($data['name']) ? $data['name'] : null, 'first_name' => !empty($data['first_name']) ? $data['first_name'] : null, 'last_name' => !empty($data['last_name']) ? $data['last_name'] : null, 'email' => strtolower($data['email']), 'email_verified' => $this->emailVerificationEnabled() ? 0 : 1, 'email_verified_at' => null, 'password' => zbase_bcrypt($data['password']), 'password_updated_at' => null, 'created_at' => zbase_date_now(), 'updated_at' => zbase_date_now(), 'deleted_at' => null];
     if (empty($user['name']) && !empty($data['first_name'])) {
         $user['name'] = $data['first_name'];
         if (!empty($data['last_name'])) {
             $user['name'] .= ' ' . $data['last_name'];
         }
     }
     if (!empty($data['role'])) {
         $user['role'] = strtolower($data['role']);
     }
     unset($data['username']);
     unset($data['name']);
     unset($data['email']);
     unset($data['password']);
     if (!empty($data['first_name'])) {
         unset($data['first_name']);
     }
     if (!empty($data['last_name'])) {
         unset($data['last_name']);
     }
     if (!empty($data['role'])) {
         unset($data['role']);
     }
     $user = array_merge_recursive($user, $data);
     return zbase_entity('user')->create($user);
 }
Esempio n. 3
0
 /**
  * Widget entity interface.
  * 	Data should be validated first before passing it here
  * @param string $method post|get
  * @param string $action the controller action
  * @param array $data validated; assoc array
  * @param Zbase\Widgets\Widget $widget
  * @return boolean
  */
 public function nodeWidgetController($method, $action, $data, \Zbase\Widgets\Widget $widget)
 {
     zbase_db_transaction_start();
     try {
         if ($action == 'create' && strtolower($method) == 'post') {
             $this->createNode($data);
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $this->_actionMessages[$action]['success'][] = _zt('Created "%title%"!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return true;
         }
         if ($action == 'update' && strtolower($method) == 'post') {
             $this->updateNode($data);
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $this->_actionMessages[$action]['success'][] = _zt('Saved "%title%"!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return true;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         zbase_db_transaction_rollback();
     }
     if ($action == 'index') {
         return;
     }
     if ($action == 'update') {
         if ($this->hasSoftDelete() && $this->trashed()) {
             $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->alphaId()]) . '" title="Restore" class="undodelete">Restore</a>';
             $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->alphaId()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
             $this->_actionMessages[$action]['warning'][] = _zt('Row "%title%" was trashed! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
             return false;
         }
     }
     if ($action == 'delete') {
         if ($this->hasSoftDelete() && $this->trashed()) {
             $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->alphaId()]) . '" title="Restore" class="undodelete">Restore</a>';
             $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->alphaId()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
             $this->_actionMessages[$action]['warning'][] = _zt('Row "%title%" was trashed! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
             return false;
         }
     }
     try {
         if (strtolower($method) == 'post') {
             if ($action == 'delete') {
                 if ($this->hasSoftDelete()) {
                     $this->deleted_at = zbase_date_now();
                     $this->save();
                 } else {
                     $this->delete();
                 }
                 $this->log($action);
                 zbase_db_transaction_commit();
                 zbase_cache_flush([$this->getTable()]);
                 $undoText = '';
                 if (!empty($this->hasSoftDelete())) {
                     $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->alphaId()]) . '" title="Undo Delete" class="undodelete">Undo</a>';
                     $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->alphaId()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
                 }
                 $this->_actionMessages[$action]['success'][] = _zt('Deleted "%title%"! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
                 return true;
             }
         }
         if ($action == 'restore') {
             if ($this->trashed()) {
                 $this->restore();
                 $this->log($action);
                 zbase_db_transaction_commit();
                 zbase_cache_flush([$this->getTable()]);
                 $this->_actionMessages[$action]['success'][] = _zt('Row "%title%" was restored!', ['%title%' => $this->title, '%id%' => $this->id()]);
                 return true;
             }
             $this->_actionMessages[$action]['error'][] = _zt('Error restoring "%title%". Row was not trashed.!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return false;
         }
         if ($action == 'ddelete') {
             if ($this->trashed()) {
                 $this->forceDelete();
                 $this->log($action);
                 zbase_db_transaction_commit();
                 zbase_cache_flush([$this->getTable()]);
                 $this->_actionMessages[$action]['success'][] = _zt('Row "%title%" forever deleted!', ['%title%' => $this->title, '%id%' => $this->id()]);
                 return true;
             }
             $this->_actionMessages[$action]['error'][] = _zt('Error restoring "%title%". Row was not trashed.!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return false;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         $this->_actionMessages[$action]['error'][] = _zt('There was a problem performing the request for "%title%".', ['%title%' => $this->title, '%id%' => $this->id()]);
         zbase_db_transaction_rollback();
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Update Row
  * @param array $data
  */
 public function postRowUpdate($data)
 {
     if (!empty($data)) {
         if ($this->postTableIsTimestampable()) {
             if (empty($data['updated_at'])) {
                 $data['updated_at'] = zbase_date_now();
             }
         }
         if (method_exists($this, 'rowUpdate')) {
             return $this->rowUpdate($data);
         }
         return $this->fill($data)->save();
     }
 }
Esempio n. 5
0
<br />
<br />
<br />
MESSAGE: -------------------
<br />
<?php 
    echo $message;
}
?>

<br />
<br />
<br />
--- DETAILS:
<?php 
$error = 'Date: ' . zbase_date_now()->format('Y-m-d h:i:s A') . "<br />";
$error .= 'URL: ' . zbase_url_uri() . "<br />";
$error .= 'Is Posting: ' . (zbase_request_is_post() ? 'Yes' : 'No') . "<br />";
$error .= 'Is AJAX: ' . (zbase_request_is_ajax() ? 'Yes' : 'No') . "<br />";
$error .= 'Data: ' . json_encode(zbase_request_inputs()) . "<br />";
$error .= 'Routes: ' . json_encode(zbase_route_inputs()) . "<br />";
$error .= 'IP Address: ' . zbase_ip() . "<br /><br /";
if (zbase_auth_has()) {
    $user = zbase_auth_user();
    $error .= 'User: '******' ' . $user->username() . '[' . $user->id() . ']' . "<br />";
}
echo $error;
?>

<?php 
echo zbase_view_render(zbase_view_file_contents('email.footer'));
Esempio n. 6
0
 /**
  * Widget entity interface.
  * 	Data should be validated first before passing it here
  * @param string $method post|get
  * @param string $action the controller action
  * @param array $data validated; assoc array
  * @param Zbase\Widgets\Widget $widget
  * @return boolean
  */
 public function nodeWidgetController($method, $action, $data, \Zbase\Widgets\Widget $widget)
 {
     zbase_db_transaction_start();
     try {
         if (strtolower($method) == 'post') {
             if ($action == 'file-update') {
                 $action = 'update';
             }
             if ($action == 'file-delete') {
                 $action = 'delete';
             }
         }
         if (strtolower($method) == 'post' && zbase_request_is_upload()) {
             $parentObject = $widget->parentEntityObject();
             if (empty($parentObject)) {
                 return false;
             }
             $this->receiveFile($parentObject);
             $action = 'create';
         }
         if (strtolower($method) == 'post') {
             if (!empty($data)) {
                 $newData = $data;
                 $data = [];
                 foreach ($newData as $dK => $dV) {
                     $data[str_replace('nodefile', '', $dK)] = $dV;
                 }
             }
         }
         if ($action == 'create' && strtolower($method) == 'post') {
             if (isset($data['title'])) {
                 $this->title = $data['title'];
             }
             if (isset($data['excerpt'])) {
                 $this->excerpt = $data['excerpt'];
             }
             $this->save();
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $this->_actionMessages[$action]['success'][] = _zt('File Uploaded!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return true;
         }
         if ($action == 'update' && strtolower($method) == 'post') {
             foreach ($data as $k => $v) {
                 unset($data[$k]);
                 $data[str_replace('nodefile', '', $k)] = $v;
             }
             if (!empty($data['status'])) {
                 $this->status = 2;
                 unset($data['status']);
             } else {
                 $this->status = 0;
             }
             if (isset($data['title'])) {
                 $this->title = $data['title'];
             }
             if (isset($data['excerpt'])) {
                 $this->excerpt = $data['excerpt'];
             }
             if (isset($data['primary']) && !empty($data['primary'])) {
                 $this->updatePrimary($data['primary']);
                 $this->parentObject()->image = $this->alphaId();
             } else {
                 $this->parentObject()->image = null;
             }
             $this->parentObject()->save();
             $this->save();
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $this->_actionMessages[$action]['success'][] = _zt('Saved', ['%title%' => $this->title, '%id%' => $this->id()]);
             return true;
         }
         if ($action == 'primary' && strtolower($method) == 'post') {
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $this->_actionMessages[$action]['success'][] = _zt('Saved', ['%title%' => $this->title, '%id%' => $this->id()]);
             return true;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         zbase_db_transaction_rollback();
     }
     if ($action == 'index') {
         return;
     }
     if ($action == 'update') {
         if ($this->hasSoftDelete() && $this->trashed()) {
             $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->id()]) . '" title="Restore" class="undodelete">Restore</a>';
             $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->id()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
             $this->_actionMessages[$action]['warning'][] = _zt('Row "%title%" was trashed! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
             return false;
         }
     }
     if ($action == 'delete') {
         if ($this->hasSoftDelete() && $this->trashed()) {
             $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->id()]) . '" title="Restore" class="undodelete">Restore</a>';
             $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->id()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
             $this->_actionMessages[$action]['warning'][] = _zt('Row "%title%" was trashed! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
             return false;
         }
     }
     try {
         if ($action == 'delete') {
             if ($this->hasSoftDelete()) {
                 $this->deleted_at = zbase_date_now();
                 $this->save();
             } else {
                 $this->_deleteFile();
                 $this->delete();
             }
             $this->log($action);
             zbase_db_transaction_commit();
             zbase_cache_flush([$this->getTable()]);
             $undoText = '';
             if (!empty($this->hasSoftDelete())) {
                 $undoText = '<a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'restore', 'id' => $this->id()]) . '" title="Undo Delete" class="undodelete">Undo</a>.';
                 $undoText .= ' | <a href="' . $widget->getModule()->url(zbase_section(), ['action' => 'ddelete', 'id' => $this->id()]) . '" title="Delete Forever " class="ddeleteforever">Delete Forever</a>';
             }
             $this->_actionMessages[$action]['success'][] = _zt('File Deleted! %undo%', ['%title%' => $this->title, '%id%' => $this->id(), '%undo%' => $undoText]);
             return true;
         }
         if ($action == 'restore') {
             if ($this->trashed()) {
                 $this->restore();
                 $this->log($action);
                 zbase_db_transaction_commit();
                 zbase_cache_flush([$this->getTable()]);
                 $this->_actionMessages[$action]['success'][] = _zt('Row "%title%" was restored!', ['%title%' => $this->title, '%id%' => $this->id()]);
                 return true;
             }
             $this->_actionMessages[$action]['error'][] = _zt('Error restoring "%title%". Row was not trashed.!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return false;
         }
         if ($action == 'ddelete') {
             if ($this->trashed()) {
                 $this->forceDelete();
                 $this->_deleteFile();
                 $this->log($action);
                 zbase_db_transaction_commit();
                 zbase_cache_flush([$this->getTable()]);
                 $this->_actionMessages[$action]['success'][] = _zt('Row "%title%" was removed from database!', ['%title%' => $this->title, '%id%' => $this->id()]);
                 return true;
             }
             $this->_actionMessages[$action]['error'][] = _zt('Error restoring "%title%". Row was not trashed.!', ['%title%' => $this->title, '%id%' => $this->id()]);
             return false;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         $this->_actionMessages[$action]['error'][] = _zt('There was a problem performing the request for "%title%".', ['%title%' => $this->title, '%id%' => $this->id()]);
         zbase_db_transaction_rollback();
     }
     return false;
 }
Esempio n. 7
0
<?php

/**
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <*****@*****.**>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Mar 20, 2016 3:02:37 PM
 * @file footer.blade.php
 * @project Expression project.name is undefined on line 13, column 15 in Templates/Scripting/EmptyPHP.php.
 * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php.
 */
?>
<br />
<br />
<hr />
IP Address: <?php 
echo zbase_ip();
?>
<br />
Date: <?php 
echo zbase_date_now()->format('Y-m-d h:i:s A');
?>
<br />
<br />
Esempio n. 8
0
 /**
  * Verify email address
  * @param string $code
  * @return boolean
  */
 public function verifyEmailAddress($code)
 {
     try {
         $verificationCode = $this->getDataOption('email_verification_code', null);
         if (!is_null($code) && $code == $verificationCode) {
             $oldEmails = $this->getDataOption('email_old');
             if (is_array($oldEmails)) {
                 $i = 0;
                 foreach ($oldEmails as $e) {
                     if ($e['new'] == $this->email()) {
                         $e['verify'] = zbase_date_now();
                         $e['verify_ip'] = zbase_ip();
                         $oldEmails[$i] = $e;
                     }
                     $i++;
                 }
             }
             if (!empty($oldEmails)) {
                 $this->setDataOption('email_old', $oldEmails);
             }
             $this->unsetDataOption('email_verification_code');
             $this->email_verified = 1;
             $this->email_verified_at = zbase_date_now();
             $this->log('user::verifyEmailAddress');
             $this->save();
             zbase_alert('info', _zt('Your email address <strong>%email%<strong> is now verified.', ['%email%' => $this->email()]));
             zbase_session_flash('user_verifyEmailAddress', true);
             return true;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         zbase_exception_throw($e);
     }
     return false;
 }