示例#1
0
 /**
  * @before _secure
  */
 public function invoice($order_id)
 {
     $this->setLayout("layouts/blank");
     $this->seo(array("title" => "Invoice", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $order = Order::first(array("id = ?" => $order_id, "user_id = ?" => $this->user->id));
     $patient = User::first(array("id = ?" => $order->user_id));
     $appointments = Appointment::all(array("order_id = ?" => $order_id));
     $instamojo = Instamojo::first(array("purpose = ?" => "order", "purpose_id = ?" => $order_id), array("payment_request_id"));
     $view->set("order", $order);
     $view->set("patient", $patient);
     $view->set("appointments", $appointments);
     $view->set("instamojo", $instamojo);
 }
    /**
     *  Implements the form() function as required by WordPress
     *  This is responsible for how the form in the WordPress admin looks
     */
    function form($instance)
    {
        $defaults = array('title' => '', 'button_text' => 'Checkout with Instamojo', 'instamojo_offer' => '', 'button_style' => 'none');
        $instance = wp_parse_args((array) $instance, $defaults);
        $instamojo_credentials = get_option('instamojo_credentials');
        if (!$instamojo_credentials['auth_token']) {
            ?>
      <p>Please authenticate your account first.</p>
      <?php 
        } else {
            // Create Instamojo instance for interacting with API
            $instamojo = new Instamojo(APPLICATION_ID);
            $instamojo->setAuthToken($instamojo_credentials['auth_token']);
            $offerObject = $instamojo->listAllOffers();
            $offers = $offerObject['offers'];
            ?>
      <p>
        <label for="<?php 
            echo $this->get_field_id('title');
            ?>
">Widget Title:</label>
        <input class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
"
          name="<?php 
            echo $this->get_field_name('title');
            ?>
"
          value="<?php 
            echo $instance['title'];
            ?>
" />
      </p>
      <p>
        <label for="<?php 
            echo $this->get_field_id('button_text');
            ?>
">Button Text:</label>
        <input class="widefat" id="<?php 
            echo $this->get_field_id('button_text');
            ?>
"
          name="<?php 
            echo $this->get_field_name('button_text');
            ?>
"
          value="<?php 
            echo $instance['button_text'];
            ?>
" />
      </p>
      <p>
        <label for="<?php 
            echo $this->get_field_id('instamojo_offer');
            ?>
">Instamojo Offer:</label>
        <select id="<?php 
            echo $this->get_field_id('instamojo_offer');
            ?>
" name="<?php 
            echo $this->get_field_name('instamojo_offer');
            ?>
">
          <option value="none" <?php 
            if ($instance['instamojo_offer'] == '') {
                echo 'selected="selected"';
            }
            ?>
>None</option>
        <?php 
            foreach ($offers as $offer) {
                ?>
          <option value="<?php 
                echo $offer['slug'];
                ?>
" <?php 
                if ($instance['instamojo_offer'] == $offer['slug']) {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                echo $offer['title'];
                ?>
</option>
        <?php 
            }
            ?>
        </select>
      </p>
      <p>
        <label for="<?php 
            echo $this->get_field_id('button_style');
            ?>
">Button Style</label>
        <select id="<?php 
            echo $this->get_field_id('button_style');
            ?>
" name="<?php 
            echo $this->get_field_name('button_style');
            ?>
">
          <option value="light" <?php 
            if ($instance['button_style'] == 'light') {
                echo 'selected="selected"';
            }
            ?>
>Light</option>
          <option value="dark" <?php 
            if ($instance['button_style'] == 'dark') {
                echo 'selected="selected"';
            }
            ?>
>Dark</option>
          <option value="flat" <?php 
            if ($instance['button_style'] == 'flat') {
                echo 'selected="selected"';
            }
            ?>
>Flat Light</option>
          <option value="flat-dark" <?php 
            if ($instance['button_style'] == 'flat-dark') {
                echo 'selected="selected"';
            }
            ?>
>Flat Dark</option>
          <option value="none" <?php 
            if ($instance['button_style'] == 'none') {
                echo 'selected="selected"';
            }
            ?>
>None</option>
        </select>
      </p>
    <?php 
        }
    }
示例#3
0
 public function generateinvoice($order_id, $instamojo_id = "not found", $action = "gen")
 {
     if ($instamojo_id == "not found") {
         $this->redirect("/patient/profile");
     }
     $view = new Framework\View(array("file" => APP_PATH . "/application/views/layouts/others/invoice.html"));
     $order = Order::first(array("id = ?" => $order_id));
     $instamojo = Instamojo::first(array("id = ?" => $instamojo_id));
     $patient = User::first(array("id = ?" => $order->user_id));
     $appointments = Appointment::all(array("order_id = ?" => $order->id));
     $view->set("order", $order);
     $view->set("patient", $patient);
     $view->set("appointments", $appointments);
     $view->set("instamojo", $instamojo);
     if (!file_exists(APP_PATH . "/public/assets/uploads/files/orders/{$order->id}.pdf")) {
         $this->generatepdf($view->render(), $order->id);
     }
     if ($action == "show") {
         $this->redirect("/public/assets/uploads/files/orders/{$order->id}.pdf");
     }
 }
 /**
  * Revoke Token
  * @param string $auth_token Auth Token stored in options
  */
 private function revoke_token($auth_token)
 {
     $instance = new Instamojo(APPLICATION_ID);
     $instance->setAuthToken($auth_token);
     $instance->deleteAuthToken();
     delete_option('instamojo_credentials');
     unset($instance);
 }