Example #1
0
    /**
     * Render fields
     *
     * @param array $invoice
     */
    function wpi_payment_fields($invoice)
    {
        $this->front_end_fields = apply_filters('wpi_crm_custom_fields', $this->front_end_fields, 'crm_data');
        if (!empty($this->front_end_fields)) {
            // For each section
            foreach ($this->front_end_fields as $key => $value) {
                // If section is not empty
                if (!empty($this->front_end_fields[$key])) {
                    $html = '';
                    ob_start();
                    ?>
          <ul class="wpi_checkout_block">
            <li class="section_title"><?php 
                    _e(ucwords(str_replace('_', ' ', $key)), WPI);
                    ?>
</li>
          <?php 
                    $html = ob_get_contents();
                    ob_end_clean();
                    echo $html;
                    // For each field
                    foreach ($value as $field_slug => $field_data) {
                        // If field is set of 3 fields for paypal phone number
                        if ($field_slug == 'phonenumber') {
                            echo '<li class="wpi_checkout_row"><div class="control-group"><label class="control-label">' . __('Phone Number', WPI) . '</label><div class="controls">';
                            $phonenumber = !empty($invoice['user_data']['phonenumber']) ? $invoice['user_data']['phonenumber'] : "---";
                            $phone_array = preg_split('/-/', $phonenumber);
                            foreach ($field_data as $field) {
                                //** Change field properties if we need */
                                $field = apply_filters('wpi_payment_form_styles', $field, $field_slug, 'wpi_paypal');
                                ob_start();
                                ?>
                  <input type="<?php 
                                echo esc_attr($field['type']);
                                ?>
" class="<?php 
                                echo esc_attr($field['class']);
                                ?>
"  name="<?php 
                                echo esc_attr($field['name']);
                                ?>
" value="<?php 
                                echo esc_attr($phone_array[key($phone_array)]);
                                next($phone_array);
                                ?>
" />
                  <?php 
                                $html = ob_get_contents();
                                ob_end_clean();
                                echo $html;
                            }
                            echo '</div></div></li>';
                        }
                        //** Change field properties if we need */
                        $field_data = apply_filters('wpi_payment_form_styles', $field_data, $field_slug, 'wpi_paypal');
                        $html = '';
                        if (!empty($field_data['type'])) {
                            switch ($field_data['type']) {
                                case self::TEXT_INPUT_TYPE:
                                    ob_start();
                                    ?>

                    <li class="wpi_checkout_row">
                      <div class="control-group">
                        <label class="control-label" for="<?php 
                                    echo esc_attr($field_slug);
                                    ?>
"><?php 
                                    _e($field_data['label'], WPI);
                                    ?>
</label>
                        <div class="controls">
                          <input type="<?php 
                                    echo esc_attr($field_data['type']);
                                    ?>
" class="<?php 
                                    echo esc_attr($field_data['class']);
                                    ?>
"  name="<?php 
                                    echo esc_attr($field_data['name']);
                                    ?>
" value="<?php 
                                    echo isset($field_data['value']) ? $field_data['value'] : (!empty($invoice['user_data'][$field_slug]) ? $invoice['user_data'][$field_slug] : '');
                                    ?>
" />
                        </div>
                      </div>
                    </li>

                    <?php 
                                    $html = ob_get_contents();
                                    ob_end_clean();
                                    break;
                                case self::SELECT_INPUT_TYPE:
                                    ob_start();
                                    ?>

                    <li class="wpi_checkout_row">
                      <label for="<?php 
                                    echo esc_attr($field_slug);
                                    ?>
"><?php 
                                    _e($field_data['label'], WPI);
                                    ?>
</label>
                  <?php 
                                    echo WPI_UI::select("name={$field_data['name']}&values={$field_data['values']}&id={$field_slug}&class={$field_data['class']}");
                                    ?>
                    </li>

                    <?php 
                                    $html = ob_get_contents();
                                    ob_clean();
                                    break;
                                default:
                                    break;
                            }
                        }
                        echo $html;
                    }
                    echo '</ul>';
                }
            }
        }
    }
Example #2
0
    /**
     * Fields renderer for STRIPE
     * @param type $invoice
     */
    function wpi_payment_fields($invoice)
    {
        $this->front_end_fields = apply_filters('wpi_crm_custom_fields', $this->front_end_fields, 'crm_data');
        if (!empty($this->front_end_fields)) {
            //** For each section */
            foreach ($this->front_end_fields as $key => $value) {
                //** If section is not empty */
                if (!empty($this->front_end_fields[$key])) {
                    $html = '';
                    ob_start();
                    ?>
          <ul class="wpi_checkout_block">
            <li class="section_title"><?php 
                    _e(ucwords(str_replace('_', ' ', $key)), WPI);
                    ?>
</li>
            <?php 
                    $html = ob_get_clean();
                    echo $html;
                    //** For each field */
                    foreach ($value as $field_slug => $field_data) {
                        //** Change field properties if we need */
                        $field_data = apply_filters('wpi_payment_form_styles', $field_data, $field_slug, 'wpi_stripe');
                        $html = '';
                        ob_start();
                        switch ($field_data['type']) {
                            case self::TEXT_INPUT_TYPE:
                                ?>

                  <li class="wpi_checkout_row">
                    <div class="control-group">
                      <label class="control-label" for="<?php 
                                echo esc_attr($field_slug);
                                ?>
"><?php 
                                _e($field_data['label'], WPI);
                                ?>
</label>
                      <div class="controls">
                        <input type="<?php 
                                echo esc_attr($field_data['type']);
                                ?>
" class="<?php 
                                echo esc_attr($field_data['class']);
                                ?>
"  name="<?php 
                                echo esc_attr($field_data['name']);
                                ?>
" value="<?php 
                                echo isset($field_data['value']) ? $field_data['value'] : (!empty($invoice['user_data'][$field_slug]) ? $invoice['user_data'][$field_slug] : '');
                                ?>
" />
                      </div>
                    </div>
                  </li>

                  <?php 
                                $html = ob_get_clean();
                                break;
                            case self::SELECT_INPUT_TYPE:
                                ?>

                  <li class="wpi_checkout_row">
                    <label for="<?php 
                                echo esc_attr($field_slug);
                                ?>
"><?php 
                                _e($field_data['label'], WPI);
                                ?>
</label>
                    <?php 
                                echo WPI_UI::select("name={$field_data['name']}&values={$field_data['values']}&id={$field_slug}&class={$field_data['class']}");
                                ?>
                  </li>

                  <?php 
                                $html = ob_get_clean();
                                break;
                            default:
                                break;
                        }
                        echo $html;
                    }
                    echo '</ul>';
                }
            }
        }
    }
                    echo '</li>';
                    break;
                case 'input_field':
                    echo '<li id="state_field"><label for="state">State</label>';                
                    echo "<input name='state' value='{$invoice[user_data][state]}' />";
                    echo '</li>';
                    break;
            }
            ?>
            <li>
                <label for="zip"><?php _e('Zip Code', WPI); ?></label>
                <input name="zip" value="<?php echo $invoice[user_data][zip];?>" />
            </li>
            <li>
                <label for="country"><?php _e('Country', WPI); ?></label>
                <?php echo WPI_UI::select("name=country&current_value={$invoice[user_data][country]}&values=countries"); ?>
            </li>
            <?php /*if($invoice['meta']['terms_acceptance_required'] == 'on') { ?>
                <li class="wpi_terms">
                    <label for="term_acceptance">&nbsp;</label>
                    <?php show_terms_acceptance(); ?>I accept the terms defined in the service agreement.
                </li>
            <?php }*/ ?>
            <li>
                <label for="submit">&nbsp;</label>
                <input type="image"  src="<?php echo $invoice['billing']['paypal']['settings']['button_url']['value']; ?>" class="paypal_button" name="submit" alt="<?php _e('Pay with PayPal', WPI); ?>">
            </li>

            <br class="cb" />    
        </ol>
    </fieldset>
  function payment($wpi_settings) { ?>
    <table class="form-table">
          <tr>
            <th><?php _e("Default Currency", WPI);?></th>
            <td><?php echo WPI_UI::select("name=wpi_settings[currency][default_currency_code]&values=".serialize($wpi_settings['currency']['types'])."&current_value={$wpi_settings['currency']['default_currency_code']}"); ?></td>
          </tr>

          <tr class="column-payment-method-default">
            <th><?php _e("Default Payment Method:", WPI) ?></th>
            <td ><select id="wp_invoice_payment_method">
                <?php foreach ($wpi_settings['installed_gateways'] as $key => $payment_option) { ?>
                <option value="<?php echo $key; ?>" <?php if($payment_option['object']->options['default_option']) { echo "SELECTED"; } ?>><?php echo $payment_option['name']; ?></option>
                <?php } ?>
              </select>&nbsp;&nbsp;
            <?php echo WPI_UI::checkbox("class=wpi_client_change_payment_method&name=wpi_settings[client_change_payment_method]&value=yes&label=".__('Client can change payment option.', WPI), WPI_Functions::is_true($wpi_settings['client_change_payment_method']))?>

            </td>
          </tr>

          <tr class='wpi-payment-setting column-paymenth-method-<?php echo $key; ?>'>
            <th><?php _e('Payment Gateways', WPI);?></th>
            <td>
            <ul>
          <?php foreach($wpi_settings['installed_gateways'] as $key => $value) { ?>
            <li>
              <?php echo WPI_UI::checkbox("&name=wpi_settings[billing][{$key}][allow]&id={$key}&value=true&label=" . $value['name'] . "&class=wpi_billing_section_show", $value['object']->options['allow']);?>
            </li>
          <?php } ?>
          </ul>
          </td>
          </tr>
          <tr>
            <th>&nbsp;</th>
            <td><div class="wp_invoice_accordion">
              <?php foreach($wpi_settings['installed_gateways'] as $key => $value) { ?>
              <div class="<?php echo $key; ?>-setup-section wp_invoice_accordion_section">
                  <h3 id="<?php echo $key; ?>-setup-section-header"><a href="#" class="selector"><?php echo $value['name'] ?></a></h3>
                  <div> <?php echo !empty($wpi_settings['billing'][$key])?WPI_UI::input("type=hidden&name=wpi_settings[billing][{$key}][default_option]&class=billing-default-option billing-{$key}-default-option&value={$wpi_settings['billing'][$key]['default_option']}"):'';?>
                    <table class="form-table">

                      <?php if ( $value['object']->options['settings'] ) foreach($value['object']->options['settings'] as $key2 => $setting_value) {
                        $setting_value['value'] = urldecode($setting_value['value']);
                        $setting_value['type'] = !empty( $setting_value['type'] ) ? $setting_value['type'] : 'input' ;
                        ?>
                      <tr>
                        <th width="300"><span class="<?php echo (!empty($setting_value['description']) ? "wp_invoice_tooltip" : ""); ?>" title="<?php echo (!empty($setting_value['description']) ? $setting_value['description'] : ''); ?>"><?php echo $setting_value['label']; ?></span></th>
                        <td>
                          <?php if ($setting_value['type'] == 'select') : ?>
                            <?php echo WPI_UI::select("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&values=" . serialize($setting_value['data']) . "&current_value={$setting_value['value']}"); ?>
                          <?php elseif ($setting_value['type'] == 'textarea') : ?>
                            <?php echo WPI_UI::textarea("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}"); ?>
                          <?php elseif ($setting_value['type'] == 'readonly') : ?>
                          <?php $setting_value['value'] = urlencode($setting_value['value']); ?>
                            <?php echo WPI_UI::textarea("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}&special=readonly='readonly'"); ?>
                          <?php else : ?>
                            <?php echo WPI_UI::input("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}"); ?>
                          <?php endif; ?>
                          <?php if (!empty($setting_value['special']) && is_array($setting_value['special']) && $setting_value['type'] != 'select') : ?>
                            <?php $s_count = 0; ?>
                            <br/>
                            <?php foreach($setting_value['special'] as $s_label => $s_value): ?>
                              <span class="wp_invoice_click_me" onclick="jQuery('input[name=\'wpi_settings[billing][<?php echo $key; ?>][settings][<?php echo $key2; ?>][value]\']').val('<?php echo $s_value; ?>');"><?php echo $s_label; ?></span>
                              <?php echo (++$s_count < count($setting_value['special']) ? ' | ' : '' ); ?>
                            <?php endforeach; ?>
                          <?php endif; ?>
                        </td>
                      </tr>
                      <?php } ?>
                    </table>
                  </div>
                </div>
                <?php } ?>
              </div></td>
          </tr>

          <tr>

            <th>
              <?php _e("Manual Payment information", WPI) ?></a>
            </th>

            <td>
              <?php echo WPI_UI::textarea("name=manual_payment_info&group=wpi_settings&value=".(!empty( $wpi_settings['manual_payment_info'] )?$wpi_settings['manual_payment_info']:''))?>
              <div class="description"><?php _e('If an invoice has no payment gateways, this message will be displayed offering the customer guidance on their course of action.', WPI) ?></div>
              </td>

          </tr>

        </table>

  <?php }
         echo '</li>';
         break;
     case 'input_field':
         echo '<li id="state_field"><label for="state">'. __('State', WPI) . '</label>';                
         echo "<input name='STATE' value='{$invoice['user_data']['state']}' />";
         echo '</li>';
         break;
 }
 ?>
 <li>
     <label for="ZIP"><?php _e('Zip Code', WPI); ?></label>
     <input name="ZIP" value="<?php echo $invoice['user_data']['zip'];?>" />
 </li>
 <li>
     <label for="COUNTRY"><?php _e('Country', WPI); ?></label>
     <?php echo WPI_UI::select("name=COUNTRY&current_value={$invoice['user_data']['country']}&values=countries"); ?>
 </li>
 
 <li>
     <label for="USER1"><?php _e('Your email', WPI); ?></label>
     <input type="text" name="USER1" size="12" value="<?php echo $invoice['user_data']['email_address'] ?>">
 </li>
 
 <li>
     <label><?php _e('The form of payment', WPI); ?></label>
     <select name="METHOD" size="1">
         <option selected value="CC"><?php _e('Credit Card', WPI); ?></option>
     </select>
 </li>
 
 <li>
          continue;

        }

        $services_array["{$service['name']}|{$service['description']}|{$service['quantity']}|{$service['price']}|{$service['tax']}"] = $service['name'] . ": " . $service['quantity'] . " x ". $service['price'];

      }

      //** Make sure there are more services than the label */

      if(count($services_array) > 1){

        $services_string = serialize($services_array);

        echo WPI_UI::select("id=wpi_predefined_services&values=$services_string&current_value=");

      }

    } ?>
      
      <input type="button" class="button wpi_button" id="wpi_add_discount" value="<?php esc_attr(_e("Add Discount", WPI)) ?>"/>

      <span id="wpi_discount_mismatch_error"></span>

    </li>

    </ul>

      <?php do_meta_boxes($screen_id, 'normal', $this_invoice->data); ?>
    <label for="country"><?php _e('Country', WPI); ?></label>
      <?php echo WPI_UI::select("name=cc_data[country]&current_value={$invoice[user_data][country]}&values=countries"); ?>
    </li>

    <li class="hide_after_success">
    <label class="inputLabel" for="cc_data[card_num]"><?php _e('Credit Card Number', WPI); ?></label>
    <input name="cc_data[card_num]" autocomplete="off" onkeyup="cc_card_pick();"  id="cc_data[card_num]" class="credit_card_number input_field"  type="text"  size="22"  maxlength="22" />
    </li>

    <li class="hide_after_success nocard"  id="cardimage" style="background: url(<?php echo $wpi_settings['frontend_path']; ?>/core/images/card_array.png) no-repeat;">
    </li>

    <li class="hide_after_success">
    <label class="inputLabel" for="exp_month"><?php _e('Expiration Date', WPI); ?></label>
    <?php _e('Month', WPI); ?> <?php echo WPI_UI::select("name=cc_data[exp_year]&values=months"); ?>
    <?php _e('Year', WPI); ?> <?php echo WPI_UI::select("name=cc_data[exp_year]&values=years"); ?>

    </li>

    <li class="hide_after_success">
    <label class="inputLabel" for="card_code"><?php _e('Security Code', WPI); ?></label>
    <input id="card_code" autocomplete="off"  name="cc_data[card_code]" class="input_field"  style="width: 70px;" type="text" size="4" maxlength="4" />
    </li>

    <li id="wp_invoice_process_wait">
    <label for="submit"><span></span>&nbsp;</label>
    <button type="submit" id="cc_pay_button" class="hide_after_success submit_button"><?php echo sprintf(__('Process Payment of %s', WPI), $invoice['meta']['currency_symbol']  . WPI_Functions::money_format($invoice['amount'])); ?></button>
    </li>  
    
  <br class="cb" />  
    </ol>
          <div>
          <?php echo WPI_UI::input("type=hidden&name=wpi_settings[billing][{$key}][default_option]&class=billing-default-option billing-{$key}-default-option&value={$wpi_settings['billing'][$key]['default_option']}")?>
            <table class="form-table">
            <?php foreach($value['settings'] as $key2 => $setting_value) {
              if ($key=='wpi_paypal' && $key2=='button_url') {
                $display="display:none;";
              } else {
                $display='';
              }
              ?>

              <tr style="<?php echo $display; ?>">
                <th width="300"><span class="<?php echo (!empty($setting_value['description']) ? "wp_invoice_tooltip" : ""); ?>" title="<?php echo (!empty($setting_value['description']) ? $setting_value['description'] : ''); ?>"><?php echo $setting_value['label']; ?></span></th>
                <td>
                  <?php if (isset($setting_value['type']) && $setting_value['type'] == 'select') : ?>
                    <?php echo WPI_UI::select("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&values=" . serialize($setting_value['data']) . "&current_value=".(!empty($setting_value['value']) ? $setting_value['value'] : "")); ?>
                  <?php elseif (isset($setting_value['type']) && $setting_value['type'] == 'textarea') : ?>
                    <?php echo WPI_UI::textarea("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}"); ?>
                  <?php elseif (isset($setting_value['type']) && $setting_value['type'] == 'readonly') : ?>
                    <?php echo WPI_UI::textarea("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}&special=readonly='readonly'"); ?>
                  <?php else : ?>
                    <?php echo WPI_UI::input("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value=".(!empty($setting_value['value']) ? $setting_value['value'] : "")); ?>
                  <?php endif; ?>
                  <?php if (!empty($setting_value['special']) && is_array($setting_value['special']) && (!isset($setting_value['type']) || $setting_value['type'] != 'select')) : ?>
                    <?php $s_count = 0; ?>
                    <br/>
                    <?php foreach($setting_value['special'] as $s_label => $s_value): ?>
                      <span class="wp_invoice_click_me" onclick="jQuery('input[name=\'wpi_settings[billing][<?php echo $key; ?>][settings][<?php echo $key2; ?>][value]\']').val('<?php echo $s_value; ?>');"><?php echo $s_label; ?></span>
                      <?php echo (++$s_count < count($setting_value['special']) ? ' | ' : '' ); ?>
                    <?php endforeach; ?>
                  <?php endif; ?>
function status_meta_box($this_invoice) {
 
    
  $hidden = '';
  if (!empty($_REQUEST['wpi']['new_invoice'])) {
    $hidden = ' hidden ';
  }
  ?>
  <div id="postbox_status_and_history" class="postbox <?php echo $hidden; ?>">
    <h3 class="hndle"><?php _e("Invoice Status and History", WPI) ?></h3>
    <div class="inside" style="margin:0;padding:0;">
      <div id="submitbox" class="submitbox" style="overflow: auto; max-height: 150px;">
        <table id="wpi_enter_payments" class="form-table hidden" >
          <tr>
            <th><?php _e("Event Type", WPI) ?></th>
            <td>
  <?php echo WPI_UI::select("name=event_type&values=" . serialize(array('add_payment' => __('Receive Payment', WPI), 'add_charge' => __('Add Charge', WPI), 'do_adjustment' => __('Administrative Adjustment', WPI)))); ?>
              <span class="wpi_recurring_options"><?php _e('Note: Recurring bills cannot have administrative adjustments or additional charges, only received payments.', WPI); ?></span>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Amount", WPI) ?></th>
            <td>
              <?php echo WPI_UI::input("type=text&name=wpi_event_amount&class=wpi_money&special=autocomplete='off'"); ?>
              <span id="event_tax_holder" class="hidden">
                <b style="padding:5px;"><?php _e("Charge Tax", WPI) ?></b><?php echo WPI_UI::input("type=text&name=wpi_event_tax&class=wpi_money&special=autocomplete='off'"); ?>%
              </span>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Date & Time", WPI) ?></th>
            <td>
              <?php echo WPI_UI::input("type=text&name=wpi_event_date&class=wpi_date"); ?>
              <?php echo WPI_UI::input("type=text&name=wpi_event_time&class=wpi_time"); ?>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Note", WPI) ?></th>
            <td><?php echo WPI_UI::input("name=wpi_event_note"); ?>
            </td>
          </tr>
          <tr>
            <th>&nbsp;</th>
            <td>
              <?php wp_nonce_field('wpi_process_manual_event_nonce', 'wpi_process_manual_event_nonce'); ?>
              <input type="button" class="button" value="<?php esc_attr(_e('Process Charge / Payment', WPI)); ?>"  id="wpi_process_manual_event" />
              <input type="button" class="button" value="<?php esc_attr(_e('Cancel', WPI)); ?>" onclick="wpi_show_paycharge_box();" />
              <span class="wpi_ajax_response"></span>
            </td>
          </tr>
        </table>
        <div style="padding: 5px;">
          <table class="form-table" id="wpi_invoice_status_table">
  <?php
  
  if (!empty($this_invoice['log']) && is_array($this_invoice['log'])) {
    if (!empty($this_invoice['ID'])) {
      WPI_Functions::get_status($this_invoice['ID']);
    }
  }
  ?>
          </table>
        </div>
      </div>
      <div class="footer_functions">
        <span class="wpi_clickable" onclick="jQuery('.wpi_event_update').toggle();"><?php _e('Toggle History Detail', WPI); ?></span>
      </div>
    </div>
  </div>
<?php
  do_action('wpi_add_comments_box');
?>
  <?php } ?>
  /**
   * Render fields
   * 
   * @param array $invoice 
   */
  function wpi_payment_fields( $invoice ) {

    $this->front_end_fields = apply_filters( 'wpi_crm_custom_fields', $this->front_end_fields, 'cc_data' );
    
    if ( !empty( $this->front_end_fields ) ) {
      // For each section
      foreach( $this->front_end_fields as $key => $value ) {
        // If section is not empty
        if ( !empty( $this->front_end_fields[ $key ] ) ) {
					$html = '';
					ob_start();
					
					?>
					<ul class="wpi_checkout_block">
						<li class="section_title"><?php _e( ucwords( str_replace('_', ' ', $key) ), WPI); ?></li>
					<?php
					$html = ob_get_contents();
					ob_end_clean();
					echo $html;
          // For each field
          foreach( $value as $field_slug => $field_data ) {

            $html = '';

            switch ( $field_data['type'] ) {
              case self::TEXT_INPUT_TYPE:

                ob_start();

                ?>

                <li class="wpi_checkout_row">
                  <label for="<?php echo esc_attr( $field_slug ); ?>"><?php _e($field_data['label'], WPI); ?></label>
                  <input type="<?php echo esc_attr( $field_data['type'] ); ?>" class="<?php echo esc_attr( $field_data['class'] ); ?>"  name="<?php echo esc_attr( $field_data['name'] ); ?>" value="<?php echo !empty($invoice['user_data'][$field_slug])?$invoice['user_data'][$field_slug]:'';?>" />
                </li>

                <?

                $html = ob_get_contents();
                ob_end_clean();

                break;

              case self::SELECT_INPUT_TYPE:

                ob_start();

                ?>

                <li class="wpi_checkout_row">
                  <label for="<?php echo esc_attr( $field_slug ); ?>"><?php _e($field_data['label'], WPI); ?></label>
                  <?php echo WPI_UI::select("name={$field_data['name']}&values={$field_data['values']}&id={$field_slug}&class={$field_data['class']}"); ?>
                </li>

                <?php

                $html = ob_get_contents();
                ob_clean();

                break;

              default:
                break;
            }

            echo $html;

          }
					echo '</ul>';
        }
      }
      
    }
    
  }
    <?php 
if (is_array($wpi_settings['predefined_services'])) {
    // Convert predefined services into special array
    $services_array[""] = __("Insert a predefined line item", WPI);
    foreach ($wpi_settings['predefined_services'] as $service) {
        // skip blanks
        if (empty($service['name'])) {
            continue;
        }
        $services_array["{$service['name']}|{$service['description']}|{$service['quantity']}|{$service['price']}|{$service['tax']}"] = $service['name'] . ": " . $service['quantity'] . " x " . $service['price'];
    }
    //** Make sure there are more services than the label */
    if (count($services_array) > 1) {
        $services_string = serialize($services_array);
        $select_data = array('id' => 'wpi_predefined_services', 'values' => $services_string, 'current_value' => '');
        echo WPI_UI::select($select_data);
    }
}
?>

      <input type="button" class="button wpi_button" id="wpi_add_discount" value="<?php 
esc_attr(_e("Add Discount", WPI));
?>
"/>

      <span id="wpi_discount_mismatch_error"></span>

    </li>

    </ul>
    /**
     * Payment tab
     *
     * @global type $wpi_chargify
     * @param type $wpi_settings
     */
    static function payment($wpi_settings)
    {
        global $wpi_chargify;
        ?>
    <table class="form-table">
      <tr>
        <th><?php 
        _e("Default Currency", WPI);
        ?>
</th>
        <td><?php 
        echo WPI_UI::select("name=wpi_settings[currency][default_currency_code]&values=" . serialize($wpi_settings['currency']['types']) . "&current_value={$wpi_settings['currency']['default_currency_code']}");
        ?>
</td>
      </tr>
      <tr>
        <th></th>
        <td>

    <?php 
        $currency_array = apply_filters('wpi_currency', $wpi_settings['currency']);
        ?>

          <div id="currency-list">
            <h3><a href="#"><?php 
        _e("Currency list", WPI);
        ?>
</a></h3>
            <div>
              <table class="ud_ui_dynamic_table widefat form-table edit-currency-tab" style="margin-bottom:8px;" auto_increment="true">
                <thead>
                  <tr>
                    <th style="width:10%; padding-left: 50px;"><?php 
        _e('Code', WPI);
        ?>
</th>
                    <th style="text-align: center;"><?php 
        _e('Symbol', WPI);
        ?>
</th>
                    <th style="width:40%; text-align: center;"><?php 
        _e('Name', WPI);
        ?>
</th>
                  </tr>
                </thead>
                <tbody>
    <?php 
        foreach ($currency_array['types'] as $slug => $title) {
            ?>
                    <tr class="wpi_dynamic_table_row" slug="<?php 
            echo $slug;
            ?>
" new_row="false">
                      <td >
                        <span class="row_delete" verify_action="true">&nbsp;</span>
      <?php 
            echo WPI_UI::input("name=wpi_settings[currency][code][{$slug}]&value={$slug}&type=text&class=" . urlencode("names_changer code") . "&special=disabled='disabled'&pattern=[A-Z]{3}&required=required&title=" . urlencode("Please,fill in the field with three capital letters (A-Z)") . "&style=width:4em;margin-left:50px;");
            ?>
                      </td>
                      <td align="left" class="symbol-row" style="text-align: center;">
      <?php 
            echo WPI_UI::input("name=wpi_settings[currency][symbol][{$slug}]&class=currency_sign&value=" . urlencode($currency_array['symbol'][$slug]) . "&type=text&required=required&style=float:right;width:150px;margin-right:55px;");
            ?>
                      </td>
                      <td>
      <?php 
            echo WPI_UI::input("name=wpi_settings[currency][types][{$slug}]&value={$title}&type=text&required=required&style=width:150px;margin-left:35px;");
            ?>
                      </td>

                    </tr>
    <?php 
        }
        ?>
                </tbody>
                <tfoot>
                  <tr>
                    <th colspan="4">
                      <input type='button' class="button wpi_button wpi_add_row" value="<?php 
        esc_attr(_e('Add Currency', WPI));
        ?>
"/>
                    </th>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
        </td>
      </tr>

      <tr class="column-payment-method-default">
        <th><?php 
        _e("Default Payment Method", WPI);
        ?>
</th>
        <td>
          <select id="wp_invoice_payment_method">
            <?php 
        foreach ((array) $wpi_settings['installed_gateways'] as $key => $payment_option) {
            ?>
                <option value="<?php 
            echo $key;
            ?>
" <?php 
            echo $payment_option['object']->options['default_option'] ? 'SELECTED' : '';
            ?>
><?php 
            echo $payment_option['name'];
            ?>
</option>
            <?php 
        }
        ?>
          </select>&nbsp;&nbsp;
        <?php 
        echo WPI_UI::checkbox("class=wpi_client_change_payment_method&name=wpi_settings[client_change_payment_method]&value=yes&label=" . __('Client can change payment option.', WPI), WPI_Functions::is_true($wpi_settings['client_change_payment_method']));
        ?>
        </td>
      </tr>

      <tr class='wpi-payment-setting column-paymenth-method-<?php 
        echo $key;
        ?>
'>
        <th><?php 
        _e('Payment Gateways', WPI);
        ?>
</th>
        <td>
          <ul>
                  <?php 
        foreach ($wpi_settings['installed_gateways'] as $key => $value) {
            ?>
              <li>
                    <?php 
            echo WPI_UI::checkbox("&name=wpi_settings[billing][{$key}][allow]&id={$key}&value=true&label=" . $value['name'] . "&class=wpi_billing_section_show", $value['object']->options['allow']);
            ?>
              </li>
    <?php 
        }
        ?>
          </ul>
        </td>
      </tr>
      <tr>
        <th>&nbsp;</th>
        <td><div class="wp_invoice_accordion">
                      <?php 
        foreach ((array) $wpi_settings['installed_gateways'] as $key => $value) {
            ?>
              <div class="<?php 
            echo $key;
            ?>
-setup-section wp_invoice_accordion_section">
                <h3 id="<?php 
            echo $key;
            ?>
-setup-section-header"><a href="#" class="selector"><?php 
            echo $value['name'];
            ?>
</a></h3>
                <div> <?php 
            echo !empty($wpi_settings['billing'][$key]) ? WPI_UI::input("type=hidden&name=wpi_settings[billing][{$key}][default_option]&class=billing-default-option billing-{$key}-default-option&value={$wpi_settings['billing'][$key]['default_option']}") : '';
            ?>
                  <table class="form-table">

                        <?php 
            if ($value['object']->options['settings']) {
                foreach ($value['object']->options['settings'] as $key2 => $setting_value) {
                    $setting_value['value'] = urldecode(isset($setting_value['value']) ? $setting_value['value'] : '');
                    $setting_value['type'] = !empty($setting_value['type']) ? $setting_value['type'] : 'input';
                    ?>
                        <tr>
                          <th width="300"><span class="<?php 
                    echo !empty($setting_value['description']) ? "wp_invoice_tooltip" : "";
                    ?>
" title="<?php 
                    echo !empty($setting_value['description']) ? $setting_value['description'] : '';
                    ?>
"><?php 
                    echo !empty($setting_value['label']) ? $setting_value['label'] : '';
                    ?>
</span></th>
                          <td>
                        <?php 
                    if ($setting_value['type'] == 'select') {
                        ?>
            <?php 
                        echo WPI_UI::select("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&values=" . serialize($setting_value['data']) . "&current_value={$setting_value['value']}");
                        ?>
          <?php 
                    } elseif ($setting_value['type'] == 'textarea') {
                        ?>
                    <?php 
                        echo WPI_UI::textarea("name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}");
                        ?>
                  <?php 
                    } elseif ($setting_value['type'] == 'readonly') {
                        ?>
                              <p class="wpi_readonly"><?php 
                        echo $setting_value['value'];
                        ?>
</p>
            <?php 
                    } elseif (isset($setting_value['type']) && $setting_value['type'] == 'static') {
                        ?>
                    <p><?php 
                        echo !empty($setting_value['data']) ? $setting_value['data'] : '';
                        ?>
</p>
          <?php 
                    } else {
                        ?>
            <?php 
                        echo WPI_UI::input("type=text&name=wpi_settings[billing][{$key}][settings][{$key2}][value]&value={$setting_value['value']}");
                        ?>
          <?php 
                    }
                    ?>
          <?php 
                    if (!empty($setting_value['special']) && is_array($setting_value['special']) && $setting_value['type'] != 'select') {
                        ?>
                  <?php 
                        $s_count = 0;
                        ?>
                              <br/>
            <?php 
                        foreach ($setting_value['special'] as $s_label => $s_value) {
                            ?>
                                <span class="wp_invoice_click_me" onclick="jQuery('input[name=\'wpi_settings[billing][<?php 
                            echo $key;
                            ?>
][settings][<?php 
                            echo $key2;
                            ?>
][value]\']').val('<?php 
                            echo $s_value;
                            ?>
');"><?php 
                            echo $s_label;
                            ?>
</span>
                    <?php 
                            echo ++$s_count < count($setting_value['special']) ? ' | ' : '';
                            ?>
                  <?php 
                        }
                        ?>
          <?php 
                    }
                    ?>
                          </td>
                        </tr>
        <?php 
                }
            }
            ?>
                  </table>
                </div>
              </div>
          <?php 
        }
        ?>
          </div></td>
      </tr>

      <tr>

        <th>
      <?php 
        _e("Manual Payment information", WPI);
        ?>
        </th>

        <td>
    <?php 
        echo WPI_UI::textarea("name=manual_payment_info&group=wpi_settings&value=" . (!empty($wpi_settings['manual_payment_info']) ? $wpi_settings['manual_payment_info'] : ''));
        ?>
          <div class="description"><?php 
        _e('If an invoice has no payment gateways, this message will be displayed offering the customer guidance on their course of action.', WPI);
        ?>
</div>
        </td>

      </tr>

    <?php 
        if (is_callable(array($wpi_chargify, 'wpi_chargify_settings'))) {
            ?>
        <tr>
          <th>
      <?php 
            _e("Subscription Payments", WPI);
            ?>
          </th>
          <td>
      <?php 
            $wpi_chargify->wpi_chargify_settings();
            ?>
          </td>
        </tr>
    <?php 
        }
        ?>

    </table>

<?php 
    }
Example #13
0
                <th width="300"><span class="<?php 
        echo !empty($setting_value['description']) ? "wp_invoice_tooltip" : "";
        ?>
" title="<?php 
        echo !empty($setting_value['description']) ? $setting_value['description'] : '';
        ?>
"><?php 
        echo !empty($setting_value['label']) ? $setting_value['label'] : '';
        ?>
</span></th>
                <td>
                  <?php 
        if (isset($setting_value['type']) && $setting_value['type'] == 'select') {
            ?>
                    <?php 
            echo WPI_UI::select(array('name' => "wpi_settings[billing][{$key}][settings][{$key2}][value]", 'values' => serialize($setting_value['data']), 'current_value' => !empty($setting_value['value']) ? $setting_value['value'] : ""));
            ?>
                  <?php 
        } elseif (isset($setting_value['type']) && $setting_value['type'] == 'textarea') {
            ?>
                    <?php 
            echo WPI_UI::textarea(array('name' => "wpi_settings[billing][{$key}][settings][{$key2}][value]", 'value' => $setting_value['value']));
            ?>
                  <?php 
        } elseif (isset($setting_value['type']) && $setting_value['type'] == 'readonly') {
            ?>
                    <?php 
            echo WPI_UI::textarea(array('name' => "wpi_settings[billing][{$key}][settings][{$key2}][value]", 'value' => $setting_value['value'], 'special' => 'readonly="readonly"'));
            ?>
                  <?php 
        } elseif (isset($setting_value['type']) && $setting_value['type'] == 'static') {