<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb): ?>
      <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php endforeach; ?>
  </div>
  <?php if ($error_warning): ?>
    <div class="warning"><?php echo $error_warning; ?></div>
  <?php endif; ?>
    
  <?php if ($success) { ?>
    <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  
  <div id="fountainG" class="ajax-loader">
    <div id="fountainG_1" class="fountainG"></div>
    <div id="fountainG_2" class="fountainG"></div>
    <div id="fountainG_3" class="fountainG"></div>
    <div id="fountainG_4" class="fountainG"></div>
    <div id="fountainG_5" class="fountainG"></div>
    <div id="fountainG_6" class="fountainG"></div>
    <div id="fountainG_7" class="fountainG"></div>
    <div id="fountainG_8" class="fountainG"></div>
  </div>
    
  <div id="InstallmentPlanInfo" style="display: none;">
    
    <div class="box">
      <div class="heading">
        <h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?> <span class="version"><?php echo $version; ?></span></h1>
        <div class="buttons">
          <a data-redirect-after-save="save" class="button"><?php echo $button_save; ?></a>
          <a data-redirect-after-save="save-and-close" class="button"><?php echo $button_save_and_close; ?></a>
          <a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a>
        </div>   
      </div>
      
      <div class="content">
        
        <div class="htabs js-block-htabs">
          <a href="#tab-content-general-settings"><?php echo $tab_general_settings; ?></a>
          <a href="#tab-content-module"><?php echo $tab_modules; ?></a>
        </div>      
        
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">

          <input type="hidden" id="time-payment-price-calculation-count" name="installment_plan_info_count" value="<?php echo $installment_plan_info_count; ?>" />
          
          <div id="tab-content-general-settings">

            <div class="vtabs">
              <div class="tab-container" style="display: none">
                <?php $setting_row = 1; ?>
                <?php foreach($installment_plan_info_settings as $content_id => $setting) { ?>
                  <a href="#tab-installment-plan-info-<?php echo $content_id; ?>" data-content_id="<?php echo $content_id; ?>" class="<?php echo $content_id == 1 ? "selected" : ""; ?>">
                    <strong>
                      <?php if($setting['tab_name']) { ?>
                        <?php echo $setting['tab_name']; ?>
                      <?php } else { ?>
                        <?php echo "{$text_content} {$setting_row}"; ?>
                      <?php }; ?>
                    </strong>
                    <img src="view/image/installment_plan_info/delete.png" alt="" />
                  </a>
                  <?php $setting_row++; ?>
                <?php }; ?>
              </div>
              <span class="button-create-new-content">
                <i><?php echo $button_create_new_content; ?></i>
                <img src="view/image/installment_plan_info/add.png" alt="" />
              </span>
            </div>


            <div class="vtabs-content-container">

              <?php foreach($installment_plan_info_settings as $content_id => $setting) { ?>

                <div id="tab-installment-plan-info-<?php echo $content_id; ?>" class="vtabs-content" data-content_id="<?php echo $content_id; ?>" style="display: <?php echo $content_id == 1 ? "block;" : "none;"; ?>">
                  <table class="form">
                    <tr>
                      <td><?php echo $entry_tab_name; ?></td>
                      <td>
                        <input type="text" class="input-tab-name" name="installment_plan_info_<?php echo $content_id; ?>[tab_name]" value="<?php echo $setting['tab_name']; ?>" />
                      </td>
                    </tr>
                    <tr>
                      <td><?php echo $entry_key; ?></td>
                      <td>
                        <input type="text" class="input-key" name="installment_plan_info_<?php echo $content_id; ?>[key]" value="<?php echo isset($setting['key']) ? $setting['key'] : ''; ?>" />
                      </td>
                    </tr>
                    <tr>
                      <td><?php echo $entry_title; ?></td>
                      <td>
                        <?php foreach ($languages as $language): ?>
                          <div class="controls">
                            <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" />
                            <input type="text" class="input-title" name="installment_plan_info_<?php echo $content_id; ?>[title][<?php echo $language['language_id']; ?>]" data-language_id="<?php echo $language['language_id']; ?>" value="<?php echo isset($setting['title'][$language['language_id']]) ? $setting['title'][$language['language_id']] : ''; ?>" />
                          </div>
                        <?php endforeach; ?>
                      </td>
                    </tr>
                    <tr>
                      <td><?php echo $entry_title_link; ?></td>
                      <td>
                        <input type="text" class="input-title-link" name="installment_plan_info_<?php echo $content_id; ?>[title_link]" value="<?php echo $setting['title_link']; ?>" />
                      </td>
                    </tr>
                    <tr>
                      <td><?php echo $entry_general_promo_message; ?></td>
                      <td>
                        <?php foreach ($languages as $language): ?>
                          <div class="controls">
                            <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" />
                            <input type="text" class="input-general-promo-message" name="installment_plan_info_<?php echo $content_id; ?>[general_promo_message][<?php echo $language['language_id']; ?>]" value="<?php echo isset($setting['general_promo_message'][$language['language_id']]) ? $setting['general_promo_message'][$language['language_id']] : ''; ?>" />
                          </div>
                        <?php endforeach; ?>
                      </td>
                    </tr>
										<tr>
											<td><?php echo $entry_stores; ?></td>
											<td>
												<div class="scrollbox-installment-plan-info-stores scrollbox">
													<?php $class = 'odd'; ?>
													<?php foreach ($stores as $store) { ?>
													<?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
													<div class="<?php echo $class; ?>">
                            <label>
                              <input type="checkbox" name="installment_plan_info_<?php echo $content_id; ?>[stores][]" value="<?php echo $store['store_id']; ?>" <?php  if (isset($setting['stores']) && in_array($store['store_id'], $setting['stores'])) echo 'checked="checked"'; ?> />
                              <?php echo $store['name']; ?>
                            </label>
													</div>
													<?php } ?>
												</div>
                        <div class="check-uncheck-all-container">
                          <a href="#" class="check-all-stores"><?php echo $text_check_all; ?></a>   
                          <a href="#" class="uncheck-all-stores"><?php echo $text_uncheck_all; ?></a>
                        </div>                        
											</td>
										</tr>                    
                    <tr>
                      <td><?php echo $entry_access_levels; ?></td>
                      <td>
                        <div class="scrollbox-installment-plan-info-access-levels scrollbox">
                          <?php $class = 'odd'; ?>
                          <?php foreach ($customer_groups as $customer_group) { ?>
                            <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                            <div class="<?php echo $class; ?>">
                              <?php if (isset($setting['access_levels']) && in_array($customer_group['customer_group_id'], $setting['access_levels'])) { ?>
                                <label>
                                  <input type="checkbox" name="installment_plan_info_<?php echo $content_id; ?>[access_levels][]" value="<?php echo $customer_group['customer_group_id']; ?>" checked="checked" />
                                  <?php echo $customer_group['name']; ?>
                                </label>
                              <?php } else { ?>
                                <label>
                                  <input type="checkbox" name="installment_plan_info_<?php echo $content_id; ?>[access_levels][]" value="<?php echo $customer_group['customer_group_id']; ?>" />
                                  <?php echo $customer_group['name']; ?>
                                </label>
                              <?php } ?>
                            </div>
                          <?php } ?>
                        </div>
                        <div class="check-uncheck-all-container">
                          <a href="#" class="check-all-access-levels"><?php echo $text_check_all; ?></a>   
                          <a href="#" class="uncheck-all-access-levels"><?php echo $text_uncheck_all; ?></a>
                        </div>
                      </td>
                    </tr>                  
                    <tr>
                      <td><?php echo $entry_stylesheet; ?></td>
                      <td>
                        <input type="hidden" class="input-hidden-use-default-stylesheet" name="installment_plan_info_<?php echo $content_id; ?>[use_default_stylesheet]" value="0" />
                        <label>
                          <input type="checkbox" class="input-checkbox-use-default-stylesheet" name="installment_plan_info_<?php echo $content_id; ?>[use_default_stylesheet]" value="1" <?php echo ($setting['use_default_stylesheet'] == 1 ? 'checked="checked"' : ''); ?> /> 
                          <?php echo $entry_use_default_stylesheet; ?>
                        </label>
                        <div class="textarea-stylesheet-container">
                          <textarea class="textarea-stylesheet" name="installment_plan_info_<?php echo $content_id; ?>[stylesheet]" cols="50" rows="3"><?php echo isset($setting['stylesheet']) ? $setting['stylesheet'] : ''; ?></textarea>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <td><?php echo $entry_payment_methods; ?></td>
                      <td>
                        <?php if ($payment_methods) { ?>
                          <ul class="payment-methods">
                            <?php $class = 'odd'; ?>
                            <?php foreach ($payment_methods as $key => $payment_method) { ?>
                              <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                              <?php reset($payment_methods); echo ($key === key($payment_methods)) ? '' : '-->' ?><li class="<?php echo $class; ?>">
                                <?php if ($payment_method['thumb']) { ?>
                                <img src="<?php echo $payment_method['thumb']; ?>" alt="<?php echo $payment_method['name']; ?>" />
                                <?php } ?>
                                <input type="hidden" class="input-hidden-payment-methods-status" name="installment_plan_info_<?php echo $content_id; ?>[payment_methods][<?php echo $key ?>][status]" value="0" />
                                <label>
                                  <input type="checkbox" class="input-checkbox-payment-methods-status" name="installment_plan_info_<?php echo $content_id; ?>[payment_methods][<?php echo $key ?>][status]" value="1" <?php echo (isset($setting['payment_methods'][$key]['status']) && $setting['payment_methods'][$key]['status'] == 1 ? 'checked="checked"' : ''); ?> />
                                  <?php echo $payment_method['name']; ?>
                                </label>
                                <input type="text" class="input-payment-methods-no-of-instal" name="installment_plan_info_<?php echo $content_id; ?>[payment_methods][<?php echo $key ?>][no_of_instal]" value="<?php echo isset($setting['payment_methods'][$key]['no_of_instal']) ? $setting['payment_methods'][$key]['no_of_instal'] : ''; ?>" maxlength="2" />
                              </li><?php end($payment_methods); echo ($key === key($payment_methods)) ? '' : '<!--' ?>
                            <?php }; ?>
                          </ul>
                        <?php }; ?>
                      </td>
                    </tr>                    
                    <tr>
                      <td><?php echo $entry_min_instal_amt; ?></td>
                      <td>
                        <?php foreach ($currencies as $currency): ?>
                          <div class="controls">
                            <label><?php echo $currency['code']; ?></label>
                            <input type="text" class="input-min-instal-amt" name="installment_plan_info_<?php echo $content_id; ?>[min_instal_amt][<?php echo $currency['code']; ?>]" value="<?php echo isset($setting['min_instal_amt'][$currency['code']]) ? $setting['min_instal_amt'][$currency['code']] : ''; ?>" />
                          </div>
                        <?php endforeach; ?>                        
                      </td>
                    </tr>                    
                  </table>
                  <table class="form form-no-border">
                    <tr>
                      <td>
                        <div class="installment-plans">
                          
                          <div class="title-installment-plans"><?php echo $entry_installment_plans; ?></div>
                          
                          <div class="table-installment-plans-wrap">
                            <?php if (isset($setting['installment_plans'])) { ?>
                              <?php foreach ($setting['installment_plans'] as $sort_order => $plan) { ?>
                                <table class="table-installment-plans">
                                  <thead>
                                    <tr>
                                      <th><?php echo $entry_no_of_instal; ?></th>
                                      <th><?php echo $entry_plan_type_and_formula_type; ?></th>
                                      <th><?php echo $entry_plan_comment; ?></th>
                                      <th><?php echo $entry_plan_promo_msg; ?></th>
                                      <th></th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td>
                                        <input type="text" class="input-no-of-instal" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][no_of_instal]" value="<?php echo $plan['no_of_instal']; ?>" maxlength="2" />
                                      </td>
                                      <td class="plan-payments-wrap">
                                        
                                        <div class="plan-type-wrap">
                                          <select class="select-plan-type" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][plan_type]">
                                            <option value="1" <?php echo (isset($plan['plan_type']) && $plan['plan_type'] == '1') ? 'selected="selected"' : ''; ?>><?php echo $text_plan_calc_meth_equal; ?></option>
                                            <option value="2" <?php echo (isset($plan['plan_type']) && $plan['plan_type'] == '2') ? 'selected="selected"' : ''; ?>><?php echo $text_plan_calc_meth_variable; ?></option>
                                          </select>
                                          <a href="#" class="button-add-indv-instl">
                                            <img src="view/image/installment_plan_info/add.png" alt="" />
                                          </a>
                                        </div>
                                        
                                        <div class="formula-type-wrap">
                                          <select class="select-formula-type" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][formula_type]">
                                            <option value=""></option>
                                            <?php foreach ($formula_types as $formula_type_key => $formula_type_name) { ?>
                                            <option value="<?php echo $formula_type_key; ?>" <?php echo (isset($plan['formula_type']) && $plan['formula_type'] == $formula_type_key) ? 'selected="selected"' : ''; ?>><?php echo $formula_type_name; ?></option>
                                            <?php } ?>
                                          </select>
                                        </div>

                                        <table class="tbl-payments">
                                          <thead>
                                            <tr>
                                              <th><?php echo $entry_installment; ?></th>
                                              <th><?php echo $entry_principal; ?></th>
                                              <th><?php echo $entry_interest; ?></th>
                                              <th><?php echo $entry_discount; ?></th>
                                              <th></th>
                                            </tr>
                                          </thead>
                                          <tbody>
                                            <?php if (isset($plan['payments']) && $plan['payments']) { ?>
                                              <?php foreach ($plan['payments'] as $payments_key => $payments_value) { ?>
                                                <tr>
                                                  <td>
                                                    <select class="select-installment" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][payments][<?php echo $payments_key; ?>][installment]">
                                                      <?php if (isset($plan['plan_type']) && $plan['plan_type'] == '1') { ?>
                                                        <option value="0" selected="selected"><?php echo $text_all; ?></option>

                                                      <?php } else if (isset($plan['plan_type']) && $plan['plan_type'] == '2') { ?>
                                                        <?php foreach (range(1, $plan['no_of_instal']) as $num) { ?>
                                                          <option value="<?php echo $num; ?>" <?php echo ($num == $payments_value['installment']) ? 'selected="selected"' : ''; ?>><?php echo $num; ?></option>
                                                        <?php } ?>
                                                      <?php } ?>
                                                    </select>
                                                  </td>
                                                  <td>
                                                    <input type="text" class="input-principal" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][payments][<?php echo $payments_key; ?>][principal]" value="<?php echo isset($payments_value['principal']) ? $payments_value['principal'] : ''; ?>" />
                                                  </td>
                                                  <td>
                                                    <input type="text" class="input-interest" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][payments][<?php echo $payments_key; ?>][interest]" value="<?php echo $payments_value['interest']; ?>" />
                                                  </td>
                                                  <td>
                                                    <input type="text" class="input-discount" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][payments][<?php echo $payments_key; ?>][discount]" value="<?php echo $payments_value['discount']; ?>" />
                                                  </td>
                                                  <td>
                                                    <?php if ($payments_key <= 0) { ?>
                                                      <a href="#" class="button-delete-indv-instl disabled">
                                                        <img src="view/image/installment_plan_info/delete_disabled.png" alt="" />
                                                      </a>
                                                    <?php } else { ?>
                                                      <a href="#" class="button-delete-indv-instl">
                                                        <img src="view/image/installment_plan_info/delete.png" alt="" />
                                                      </a>
                                                    <?php } ?>
                                                  </td>
                                                </tr>
                                              <?php } ?>
                                            <?php } ?>
                                          </tbody>
                                        </table>
                                      </td>
                                      <td>
                                        <?php foreach ($languages as $language): ?>
                                          <div class="controls">
                                            <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" />
                                            <input type="text" class="input-plan-comment" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][comment][<?php echo $language['language_id']; ?>]" value="<?php echo isset($plan['comment'][$language['language_id']]) ? $plan['comment'][$language['language_id']] : ''; ?>" />
                                          </div>
                                        <?php endforeach; ?>              
                                      </td>
                                      <td>
                                        <?php foreach ($languages as $language): ?>
                                          <div class="controls">
                                            <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" />
                                            <input type="text" class="input-plan-promo-msg" name="installment_plan_info_<?php echo $content_id; ?>[installment_plans][<?php echo $sort_order; ?>][promo_msg][<?php echo $language['language_id']; ?>]" value="<?php echo isset($plan['promo_msg'][$language['language_id']]) ? $plan['promo_msg'][$language['language_id']] : ''; ?>" />
                                          </div>
                                        <?php endforeach; ?>              
                                      </td>
                                      <td>
                                        <a href="#" class="button-delete-instal-plan">
                                          <img src="view/image/installment_plan_info/delete.png" alt="" />
                                        </a>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                              <?php } ?>
                            <?php } ?>
                          </div>
                          <div class="button-add-instal-plan ipi-button">
                            <img src="view/image/installment_plan_info/add.png" alt="" />
                            <a href="#"><?php echo $button_add_installment_plan; ?></a>
                          </div>                          
                        </div>
                      </td>                        
                    </tr>                  
                  </table>
                  
                </div>
              <?php }; // END of foreach ?>
            </div>
            <!-- /.vtabs-content-container -->
          </div>
          <!-- /#tab-content-general-settings -->
          
          
          <div id="tab-content-module">

            <table id="module" class="list">
              <thead>
                <tr>
                  <td class="left"><?php echo $entry_content_id; ?></td>
                  <td class="left"><?php echo $entry_image; ?></td>
                  <td class="left"><?php echo $entry_layout; ?></td>
                  <td class="left"><?php echo $entry_position; ?></td>
                  <td class="left"><?php echo $entry_status; ?></td>
                  <td class="right"><?php echo $entry_sort_order; ?></td>
                  <td></td>
                </tr>
                <tr class="filter" style="display: none">
                  <td><input type="text" name="filter_module_content_id" data-class=".select-module-content-id" value="" size="15" /></td> 
                  <td>
                    <input type="text" name="filter_module_image_width" data-class=".input-module-image-width" value="" size="3" />
                    <input type="text" name="filter_module_image_height" data-class=".input-module-image-height" value="" size="3" />
                  </td>
                  <td align="left"><input type="text" name="filter_module_layout_name" data-class=".select-module-layout-id" value="" size="15"/></td>
                  <td align="left"><input type="text" name="filter_module_position" data-class=".select-module-position" value="" size="15" /></td>
                  <td>
                    <select name="filter_module_status" data-class=".select-module-status">
                      <option value="*"></option>
                      <option value="1"><?php echo $text_enabled; ?></option>
                      <option value="0"><?php echo $text_disabled; ?></option>
                    </select>
                  </td>
                  <td align="right"><input type="text" name="filter_module_sort_order" data-class=".input-module-sort-order" value="" size="3" /></td>
                  <td><a id="button-clear-filters" class="button"><?php echo $button_clear_filters; ?></a></td>
                </tr>           
              </thead>
              <?php $module_row = 0; ?>
              <?php foreach ($modules as $module): ?>
                <tbody id="module-row<?php echo $module_row; ?>">
                  <tr>
                    <td class="left">
                      <select class="select-module-content-id" name="installment_plan_info_module[<?php echo $module_row; ?>][content_id]">
                        <option value=""></option>
                        <?php $setting_row = 1; ?>
                        <?php foreach($installment_plan_info_settings as $content_id => $setting) { ?>
                          <?php if (isset($module['content_id']) && $module['content_id'] == $content_id) { ?>
                             <option value="<?php echo $content_id; ?>" selected="selected">
                               <?php if ($setting['tab_name']) { ?>
                                 <?php echo $setting['tab_name']; ?>
                               <?php } else { ?>
                                 <?php echo "{$text_content} {$setting_row}"; ?>
                               <?php } ?>                          
                             </option>
                           <?php } else { ?>
                             <option value="<?php echo $content_id; ?>">
                               <?php if ($setting['tab_name']) { ?>
                                 <?php echo $setting['tab_name']; ?>
                               <?php } else { ?>
                                 <?php echo "{$text_content} {$setting_row}"; ?>
                               <?php } ?>                          
                             </option>
                           <?php } ?>
                          <?php $setting_row++; ?>
                        <?php }; ?>                        
                      </select>
                      <?php if (isset($error_content_id[$module_row])) { ?>
                        <span class="error"><?php echo $error_content_id[$module_row]; ?></span>
                      <?php } ?>                                            
                    </td>                                
                    <td class="left">
                      <input type="text" class="input-module-image-width" name="installment_plan_info_module[<?php echo $module_row; ?>][image_width]" value="<?php echo $module['image_width']; ?>" size="3" />
                      <input type="text" class="input-module-image-height" name="installment_plan_info_module[<?php echo $module_row; ?>][image_height]" value="<?php echo $module['image_height']; ?>" size="3" />
                      <?php if (isset($error_image[$module_row])) { ?>
                        <span class="error"><?php echo $error_image[$module_row]; ?></span>
                      <?php } ?>
                    </td>
                    <td class="left">
                      <select class="select-module-layout-id" name="installment_plan_info_module[<?php echo $module_row; ?>][layout_id]">
                        <?php foreach ($layouts as $layout) { ?>
                          <?php if ($layout['layout_id'] == $module['layout_id']) { ?>
                            <option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
                          <?php } else { ?>
                            <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
                          <?php } ?>
                        <?php } ?>
                      </select>
                    </td>
                    <td class="left">
                      <select class="select-module-position" name="installment_plan_info_module[<?php echo $module_row; ?>][position]">
                        <?php if ($module['position'] == 'content_top') { ?>
                          <option value="content_top" selected="selected"><?php echo $text_content_top; ?></option>
                        <?php } else { ?>
                          <option value="content_top"><?php echo $text_content_top; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'content_bottom') { ?>
                          <option value="content_bottom" selected="selected"><?php echo $text_content_bottom; ?></option>
                        <?php } else { ?>
                          <option value="content_bottom"><?php echo $text_content_bottom; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'column_left') { ?>
                          <option value="column_left" selected="selected"><?php echo $text_column_left; ?></option>
                        <?php } else { ?>
                          <option value="column_left"><?php echo $text_column_left; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'column_right') { ?>
                          <option value="column_right" selected="selected"><?php echo $text_column_right; ?></option>
                        <?php } else { ?>
                          <option value="column_right"><?php echo $text_column_right; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'installment_plan_info') { ?>
                          <option value="installment_plan_info" selected="selected"><?php echo $text_custom_position; ?></option>
                        <?php } else { ?>
                          <option value="installment_plan_info"><?php echo $text_custom_position; ?></option>
                        <?php } ?>
                      </select>
                    </td>
                    <td class="left">
                      <select class="select-module-status" name="installment_plan_info_module[<?php echo $module_row; ?>][status]">
                        <?php if ($module['status']) { ?>
                          <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                          <option value="0"><?php echo $text_disabled; ?></option>
                        <?php } else { ?>
                          <option value="1"><?php echo $text_enabled; ?></option>
                          <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                        <?php } ?>
                      </select>
                    </td>
                    <td class="right"><input type="text" class="input-module-sort-order" name="installment_plan_info_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $module['sort_order']; ?>" size="3" /></td>
                    <td class="left"><a href="#" class="button"><?php echo $button_remove; ?></a></td>
                  </tr>
                </tbody>
                <?php $module_row++; ?>
              <?php endforeach; ?>
              <tfoot>
                <tr>
                  <td colspan="6"></td>
                  <td class="left"><a id="button-add-module" class="button"><?php echo $button_add_module; ?></a></td>
                </tr>
              </tfoot>
            </table>                    
          </div>
          <!-- /#tab-content-module -->

        </form>
      </div>
      <!-- /.content -->
    </div>
    
    <input type="hidden" id="token" name="token" value="<?php echo $token; ?>" />
    <input type="hidden" id="module-row" name="module-row" value="<?php echo $module_row; ?>" />
    
  </div>
  <!-- /#installmentPlanInfo -->  
</div>

<script type="text/javascript">//<![CDATA[
  $(function() {
    
    var options = {};
    
    // Translations
    options['translations'] = {
      'text_content': '<?php echo $text_content; ?>',
      'text_confirm_delete_content': '<?php echo $text_confirm_delete_content; ?>',
      'text_content_top': '<?php echo $text_content_top; ?>',
      'text_content_bottom': '<?php echo $text_content_bottom; ?>',
      'text_column_left': '<?php echo $text_column_left; ?>',
      'text_column_right': '<?php echo $text_column_right; ?>',
      'text_custom_position': '<?php echo $text_custom_position; ?>',
      'text_enabled': '<?php echo $text_enabled; ?>',
      'text_disabled': '<?php echo $text_disabled; ?>',
      'text_check_all': '<?php echo $text_check_all; ?>',
      'text_uncheck_all': '<?php echo $text_uncheck_all; ?>',
      'text_plan_calc_meth_equal': '<?php echo $text_plan_calc_meth_equal; ?>',
      'text_plan_calc_meth_variable': '<?php echo $text_plan_calc_meth_variable; ?>',
      'text_all': '<?php echo $text_all; ?>',
      'entry_tab_name': '<?php echo $entry_tab_name; ?>',
      'entry_key': '<?php echo $entry_key; ?>',
      'entry_title': '<?php echo $entry_title; ?>',
      'entry_title_link': '<?php echo $entry_title_link; ?>',
      'entry_general_promo_message': '<?php echo $entry_general_promo_message; ?>',
      'entry_installment_plans': '<?php echo $entry_installment_plans; ?>',
      'entry_no_of_instal': '<?php echo $entry_no_of_instal; ?>',
      'entry_plan_type_and_formula_type': '<?php echo $entry_plan_type_and_formula_type; ?>',
      'entry_installment': '<?php echo $entry_installment; ?>',
      'entry_principal': '<?php echo $entry_principal; ?>',
      'entry_interest': '<?php echo $entry_interest; ?>',
      'entry_discount': '<?php echo $entry_discount; ?>',
      'entry_plan_comment': '<?php echo $entry_plan_comment; ?>',
      'entry_plan_promo_msg': '<?php echo $entry_plan_promo_msg; ?>',
      'entry_payment_methods': '<?php echo $entry_payment_methods; ?>',
      'entry_min_instal_amt': '<?php echo $entry_min_instal_amt; ?>',
      'entry_stores': '<?php echo $entry_stores; ?>',
      'entry_access_levels': '<?php echo $entry_access_levels; ?>',
      'entry_stylesheet': '<?php echo $entry_stylesheet; ?>',
      'entry_use_default_stylesheet': '<?php echo $entry_use_default_stylesheet; ?>',
      'button_remove': '<?php echo $button_remove; ?>',
      'button_add_installment_plan': '<?php echo $button_add_installment_plan; ?>'
    }    

    // Languages
    var _languages = [];
    
    <?php if ($languages) { ?>
      <?php if (IS_MIJOSHOP) { ?>
        <?php foreach ($languages as $language) { ?>
          // MijoShop will automatically convert this to something like: "http://example.com/media/mod_languages/images/en.gif" 
          var _src = '<?php echo "src=\"view/image/flags/{$language['image']}\""; ?>';
          _languages.push({
            'language_id': '<?php echo $language['language_id']; ?>',
            'name': '<?php echo $language['name']; ?>',
            'src': _src.replace(/^src=\"(.*?)\"$/g, '$1') // Strip html tags and get a plain src only inside.
          });          
        <?php } ?>        
      <?php } else { ?>        
        <?php foreach ($languages as $language) { ?>
          _languages.push({
            'language_id': '<?php echo $language['language_id']; ?>',
            'name': '<?php echo $language['name']; ?>',
            'src': 'view/image/flags/<?php echo $language['image']; ?>' 
          });
        <?php } ?>
      <?php } ?>
    <?php } ?>    
    
    options['languages'] = _languages;
    
    // Payment Methods
    options['payment_methods'] = <?php echo json_encode($payment_methods); ?>;
    
    // Currencies
    options['currencies'] = <?php echo json_encode($currencies); ?>;
    
    // Formulas
    options['formula_types'] = <?php echo json_encode($formula_types); ?>;
    
    // Stores
    options['stores'] = <?php echo json_encode($stores); ?>;
    
    // Customer Groups
    options['customer_groups'] = <?php echo json_encode($customer_groups); ?>;
    
    // Layouts
    options['layouts'] = <?php echo json_encode($layouts); ?>;
    
    // Image base URL
    // MijoShop will automatically convert this to "../components/com_mijoshop/opencart/admin/view/image/installment_plan_info/"
    options['image_base_url'] = 'view/image/installment_plan_info/';
    
    // Button class
    var _button_class = '';
    <?php if (IS_MIJOSHOP) { ?>
      // MijoShop will automatically convert this to "button_oc" 
      _button_class = '<?php echo "class=\"button\""; ?>'.replace(/^class=\"(.*?)\"$/g, '$1');
    <?php } else { ?>
      _button_class = 'button';
     <?php } ?>  
    options['button_class'] = _button_class;
    
    // Determine if it's running on MijoShop or not.
    options['is_mijoshop'] = <?php echo (int)IS_MIJOSHOP; ?>;
    
    // Initialize the plugin
    $("#InstallmentPlanInfo").installmentPlanInfo(options);

  });
//]]></script>

<?php echo $footer; ?>