Example #1
0
 /**
  *  onRun function
  */
 public function onRun()
 {
     // $this->prepareVars();
     $this->courses = $this->page['courses'] = $this->listCourses();
     // $order_messages = Session::get('order_messages');
     $this->order_state = $this->page['order_state'] = Session::get('order_state');
     \CW::info(['Session' => $this->order_state]);
 }
Example #2
0
 public static function run($config = [], $isConsoleApp = false, $path = '')
 {
     static $inst = null;
     if (null === $inst) {
         $inst = new self($isConsoleApp);
         \CW::$app = $inst;
         $inst->components = isset($config['components']) ? $config['components'] : [];
         $inst->params = isset($config['params']) ? $config['params'] : [];
         if (!$isConsoleApp) {
             $inst->dispatch($inst->getPath($path));
         }
     }
 }
Example #3
0
 /**
  *  onRun function
  */
 public function onRun()
 {
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/transition.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/dropdown.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/checkbox.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/form.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/button.css');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/transition.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/dropdown.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/checkbox.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/form.js');
     // $this->addJs('/themes/mrc/assets/vendor/semantic/components/button.js');
     \CW::info([$this->user()->profile]);
     $this->profile = $this->page['profile'] = $this->user()->profile;
 }
Example #4
0
 protected function loadPost()
 {
     $slug = $this->property('slug');
     $post = PostModel::isPublished()->where('slug', $slug)->first();
     if (!$post) {
         return null;
     }
     $prev = PostModel::isPublished()->where('published_at', '<', $post->published_at)->orderBy('published_at', 'desc')->first();
     $next = PostModel::isPublished()->where('published_at', '>', $post->published_at)->orderBy('published_at', 'asc')->first();
     if (!is_null($prev)) {
         $this->prev = $this->page['prev'] = $prev->setUrl('news/post', $this->controller);
     }
     if (!is_null($next)) {
         $this->next = $this->page['next'] = $next->setUrl('news/post', $this->controller);
     }
     \CW::info([$this->prev, $this->next]);
     // CW::info(['News' => $post]);
     return $post;
 }
Example #5
0
CW API 2015
api@checkwa.com
******************************************/
error_reporting(E_ALL);
ini_set("display_errors", 1);
date_default_timezone_set('Europe/Madrid');
/***************** Example config ************************/
$user = "******";
// Get your user and password: contact with api@checkwa.com
$password = "******";
$prefix = $_POST['prefix'];
$number = $_POST['number'];
/*********************************************************/
include "cw-class/class.cw.php";
include "cw-class/emoji.php";
$_cw = new CW();
$cw = json_decode($_cw->Get($user, $password, $prefix, $number), true);
if ($cw['response'] == "1") {
    if ($cw['result'] == "Y") {
        echo '<div class="cw_yeswhatsapp">Yes! That number uses WhatsApp</div>';
        // THAT NUMBER USE WHATSAPP
        ?>
<div class="cw_num"><?php 
        if (!empty($cw['prefix'])) {
            echo $cw['prefix'];
        }
        //PREFIX
        if (!empty($cw['number'])) {
            echo $cw['number'] . "<br>";
        }
        //NUMBER
Example #6
0
<?php

class CW
{
    public static $app;
    public static function autoload()
    {
        spl_autoload_register(function ($className) {
            global $params;
            $className = str_replace('\\', '/', $className);
            $file = __DIR__ . "/{$className}.php";
            if (is_file($file)) {
                include __DIR__ . "/{$className}.php";
            }
        });
    }
}
CW::autoload();
Example #7
0
 /**
  * Update Events from CRM
  */
 public function onUpdateFromCrm()
 {
     $crmuserevents = CRMUserEvent::isNotUpdated()->with(['user', 'event'])->get();
     \CW::info(['userevents' => $crmuserevents]);
     if (count($crmuserevents) == 0) {
         Flash::info("No UserEvents to Create/Update");
         // echo "ERROR!";
         return;
     }
     $crmuserevents->each(function ($userevent) {
         if ($userevent->user && $userevent->event) {
             \CW::info([$userevent]);
             $cmsuser = User::where('email', $userevent->user->email)->first();
             $cmsevent = Event::where('crm_event_id', $userevent->event->id)->with('course')->first();
             $cmscourse = $cmsevent->course;
             $cmsusereventstate = UserEventState::where('crm_state_id', $userevent->state_id)->first();
             // $cmsuserevent = UserEvent::firstOrNew(['crm_event_id' => $userevent->event->id, 'user_id' => $cmsuser->id]);
             // $cmsuserevent = $cmsuser->userevents()
             // $cmsuserevent = $cmsuserevent
             $cmsuserevent = UserEvent::where('user_id', $cmsuser->id)->where('event_id', $cmsevent->id)->first();
             if (!$cmsuserevent) {
                 $cmsuserevent = new UserEvent();
             }
             \CW::info([$cmsuser, $cmsevent, $cmscourse, $cmsuserevent, $cmsusereventstate]);
             // if (!$cmsuser) {
             //     Log::warning("CMSUser is NULL\n");
             // }
             // if (!$cmsevent) {
             //     Log::warning("CMSEvent is NULL\n");
             // }
             // if (!$cmscourse) {
             //     Log::warning("CMSCourse is NULL\n");
             // }
             // if (!$cmsuserevent) {
             //     Log::warning("CMSUserEvent is NULL\n");
             // }
             // if (!$cmsusereventstate) {
             //     Log::warning("CMSUserEventState is NULL\n");
             // }
             $cmsuserevent->user()->associate($cmsuser);
             $cmsuserevent->course()->associate($cmscourse);
             $cmsuserevent->state()->associate($cmsusereventstate);
             $cmsuserevent->event()->associate($cmsevent);
             $cmsuserevent->fill(['course_type_id' => $cmscourse->course_type_id, 'course_category_id' => $cmscourse->course_category_id, 'crm_event_id' => $userevent->event->id]);
             \CW::info([$cmsuserevent]);
             $cmsuserevent->save();
             $userevent->update(['is_updated' => true]);
         }
     });
     Flash::success("UserEvents is update");
 }