Пример #1
0
    function JLMS_subscriptionsList($rows, $pageNav, $option, $lists)
    {
        ?>
		<script language="javascript">
		function submitbutton(pressbutton) {
			if(pressbutton == 'assign') {
				if (document.adminForm.boxchecked.value == 0) { 
						alert('<?php 
        echo _JLMS_SUBS_SELECT_SUBS_FROM_LIST;
        ?>
');
				}
				else {
					submitform(pressbutton);
				}
			}	
			else{
				submitform(pressbutton);
			}
		}
		<?php 
        if (JLMS_J16version()) {
            ?>
		Joomla.submitbutton = submitbutton;
		<?php 
        }
        ?>
		</script>
		<form action="index.php" method="post" name="adminForm">		
<table width="100%" >
	<tr>
	<td valign="top" width="220">
	<div>
		<?php 
        joomla_lms_adm_html::JLMS_menu();
        ?>
	</div>
	</td>
	<td valign="top">	
		<table cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="left" width="100%">&nbsp;</td>
			<td nowrap="nowrap">
				<table class="adminlist">
				<tr class="row1">	
					<td nowrap="nowrap" style="padding:2px 10px 2px 10px;"><?php 
        echo _JLMS_SUBS_STATUS;
        ?>
:&nbsp;&nbsp;</td>			
					<td nowrap="nowrap" style="padding:2px 10px 2px 10px;"><?php 
        echo $lists['status_filter'];
        ?>
</td>
				</tr>			
				</table>
			</td>
		</tr>
		</table>			
		<table width="100%" border="0">
			<tr>
				<td valign="top">
					<table class="adminlist" width="100%">
					<thead>
						<tr>
							<th width="20px">#</th>
							<th width="20px" class="title"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
        echo count($rows);
        ?>
);" /></th>
							<th class="title" width="150px"><?php 
        echo _JLMS_SUBS_SUBSCRIPTION_NAME;
        ?>
</th>
							<th class="title" width="150px"><?php 
        echo _JLMS_COURSES;
        ?>
</th>
							<th class="title" width="100px"><?php 
        echo _JLMS_TYPE;
        ?>
</th>
							<th class="title" width="100px"><?php 
        echo _JLMS_START_DATE;
        ?>
</th>
							<th class="title" width="100px"><?php 
        echo _JLMS_END_DATE;
        ?>
</th>
							<th class="title" width="70px"><?php 
        echo _JLMS_PUBLISHED;
        ?>
</th>
							<th class="title" width="40px"><?php 
        echo _JLMS_PRICE;
        ?>
</th>
							<th class="title" width="140px"><?php 
        echo _JLMS_DATE;
        ?>
</th>
							<th class="title" width="30"><?php 
        echo _JLMS_ID;
        ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="11">
							<?php 
        echo $pageNav->getListFooter();
        ?>
							</td>
						</tr>
					</tfoot>
					<tbody>
					<?php 
        $k = 0;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row = $rows[$i];
            $img_published = $row->published ? 'tick.png' : 'publish_x.png';
            $task_published = $row->published ? 'unpublish_subscription' : 'publish_subscription';
            $alt_published = $row->published ? _JLMS_PUBLISHED : _JLMS_UNPUBLISHED;
            $checked = mosHTML::idBox($i, $row->id);
            ?>
						<tr class="<?php 
            echo "row{$k}";
            ?>
">
							<td><?php 
            echo $pageNav->rowNumber($i);
            ?>
</td>
							<td><?php 
            echo $checked;
            ?>
</td>

							<td align="left">
								<?php 
            echo "<a href='index.php?option={$option}&amp;task=editA_subscription&amp;id=" . $row->id . "' >" . $row->sub_name . "</a>";
            ?>
							</td>
							<td align="left">
								<?php 
            $db =& JFactory::GetDbo();
            $query = "SELECT course_name FROM `#__lms_subscriptions_courses` as a, `#__lms_courses` as b WHERE a.sub_id = '" . $row->id . "' AND a.course_id = b.id ";
            $db->setQuery($query);
            $courses = $db->loadObjectList();
            foreach ($courses as $course) {
                echo $course->course_name . "<br />";
            }
            ?>
							</td>
							<td align="left">
								<?php 
            $start_date = '-';
            $end_date = '-';
            if ($row->account_type == 1) {
                echo _JLMS_BASIC;
            } elseif ($row->account_type == 2) {
                echo _JLMS_DATE_TO_DATE;
                $start_date = $row->start_date;
                $end_date = $row->end_date;
            } elseif ($row->account_type == 3) {
                echo _JLMS_DATE_TO_LIFETIME;
                $start_date = $row->start_date;
                $end_date = 'Lifetime';
            } elseif ($row->account_type == 4) {
                echo _JLMS_X_DAYS_ACCESS;
                $start_date = _JLMS_SUBS_DAY_OF_PAYMENT;
                $end_date = '+' . $row->access_days . ' ' . _JLMS_SUBS_DAYS;
            } elseif ($row->account_type == 5) {
                echo _JLMS_WITH_DISCOUNT;
            } elseif (isset($row->plan_name)) {
                echo $row->plan_name;
            }
            ?>
							</td>
							<td align="left">
								<?php 
            echo $start_date;
            ?>
							</td>
							<td align="left">
								<?php 
            echo $end_date;
            ?>
							</td>
							<td align="center">
								<a href="javascript: void(0);" onclick="return listItemTask('cb<?php 
            echo $i;
            ?>
','<?php 
            echo $task_published;
            ?>
')">
									<img src="<?php 
            echo ADMIN_IMAGES_PATH . $img_published;
            ?>
" border="0" alt="<?php 
            echo $alt_published;
            ?>
" />
								</a>
							</td>
							<td align="left" nowrap="nowrap"><?php 
            if ($row->account_type == 5 && round($row->discount, 2)) {
                printf('%.2f', round($row->price, 2));
                echo " - " . round($row->discount, 2) . "% = ";
                printf('%.2f', round($row->price - $row->price * $row->discount / 100, 2));
            } else {
                if ($row->account_type == 6) {
                    echo JLMS_RECURRENT_PAY::getPriceDesc($row);
                } else {
                    if ($row->account_type == 5) {
                        echo "<font color='red'>";
                    }
                    printf('%.2f', round($row->price, 2));
                    if ($row->account_type == 5) {
                        echo "</font>";
                    }
                }
            }
            ?>
							</td>
							<td align="left">
								<?php 
            echo $row->date;
            ?>
							</td>
							<td><?php 
            echo $row->id;
            ?>
</td>
						</tr>
						<?php 
            $k = 1 - $k;
        }
        ?>
					</tbody>
					</table>
				</td>
			</tr>
		</table>		
</td></tr></table>
		<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
		<input type="hidden" name="task" value="subscriptions" />
		<input type="hidden" name="boxchecked" value="0" />

		<input type="hidden" name="hidemainmenu" value="0" />		
		</form>
		<?php 
    }
Пример #2
0
 function getPriceDesc(&$subscription, $showType = 'default', $balance = 0, $amount = 0)
 {
     global $JLMS_CONFIG;
     if (!isset($subscription->p1)) {
         $obj = JLMS_RECURRENT_PAY::getObjByReccSubsId($subscription->id);
         foreach (get_object_vars($obj) as $key => $value) {
             $subscription->{$key} = $value;
         }
     }
     /* else {
     			$obj = php4_clone( $subscription );	
     		}	
     		*/
     JLMS_RECURRENT_PAY::initPricesObjects($subscription);
     JLMS_RECURRENT_PAY::recalcSubsParams($subscription, $showType, $balance, $amount);
     $marks = array('{a1}' => $subscription->price1->getCalcPath(), '{a2}' => $subscription->price2->getCalcPath(), '{a3}' => $subscription->price3->getCalcPath(), '{p1}' => $subscription->price1->get('p'), '{p2}' => $subscription->price2->get('p'), '{p3}' => $subscription->price3->get('p'));
     $marks['{free}'] = "";
     $marks['{then}'] = "";
     $marks['{next}'] = "";
     $marks['{srt}'] = $subscription->price3->get('srt');
     $part1 = $part2 = $part3 = $part4 = '';
     $marks['{cur}'] = $JLMS_CONFIG->get('jlms_cur_code');
     if ($subscription->price1->showPrice() || $subscription->price1->isPeriodTrial()) {
         if ($subscription->price1->isPeriodTrial()) {
             $marks['{free}'] = _JLMS_RECURRENT_PAYMENT_FREE;
             $marks['{a1}'] = "";
             $marks['{cur}'] = "";
         }
         if ($subscription->price1->get('p') == 1) {
             $part1 = strtr(_JLMS_RECURRENT_PAYMENT_FIRST_DAY, $marks);
         } else {
             $part1 = strtr(_JLMS_RECURRENT_PAYMENT_FIRST_DAYS, $marks);
         }
         $part1 .= "<br />";
     }
     $marks['{cur}'] = $JLMS_CONFIG->get('jlms_cur_code');
     $marks['{free}'] = "";
     if ($subscription->price2->showPrice()) {
         if ($subscription->price1->showPrice() || $subscription->price1->isPeriodTrial()) {
             $marks['{then}'] = _JLMS_RECURRENT_PAYMENT_THEN;
             $marks['{next}'] = _JLMS_RECURRENT_PAYMENT_THE_NEXT;
         }
         if ($subscription->price2->get('p') == 1) {
             $part2 = strtr(_JLMS_RECURRENT_PAYMENT_NEXT_DAY, $marks);
         } else {
             $part2 = strtr(_JLMS_RECURRENT_PAYMENT_NEXT_DAYS, $marks);
         }
         $part2 .= "<br />";
     }
     $marks['{cur}'] = $JLMS_CONFIG->get('jlms_cur_code');
     if ($subscription->src && $subscription->price3->get('srt') > 0) {
         if ($subscription->price1->showPrice() || $subscription->price2->showPrice()) {
             $marks['{then}'] = _JLMS_RECURRENT_PAYMENT_THEN;
         } else {
             $marks['{then}'] = '';
         }
         if ($subscription->price3->get('a')) {
             if ($subscription->price3->get('p') == 1) {
                 $part4 = strtr(_JLMS_RECURRENT_PAYMENT_INSTALLMENTS, $marks);
             } else {
                 $part4 = strtr(_JLMS_RECURRENT_PAYMENT_INSTALLMENTS_DAYS, $marks);
             }
             $part4 .= "<br />";
         }
     } else {
         if ($subscription->src) {
             if ($subscription->price1->showPrice() || $subscription->price2->showPrice()) {
                 $marks['{then}'] = _JLMS_RECURRENT_PAYMENT_THEN;
             } else {
                 $marks['{then}'] = '';
             }
             if ($subscription->price3->get('a')) {
                 if ($subscription->price3->get('p') == 1) {
                     $part4 = strtr(_JLMS_RECURRENT_PAYMENT_FOREACH, $marks);
                 } else {
                     $part4 = strtr(_JLMS_RECURRENT_PAYMENT_FOREACH_DAYS, $marks);
                 }
                 $part4 .= "<br />";
             }
         } else {
             if ($subscription->price1->showPrice() || $subscription->price2->showPrice()) {
                 $marks['{then}'] = _JLMS_RECURRENT_PAYMENT_THEN;
             } else {
                 $marks['{then}'] = '';
             }
             if ($subscription->price3->get('a')) {
                 if ($subscription->price3->get('p') == 1) {
                     $part3 = strtr(_JLMS_RECURRENT_PAYMENT_ONE_DAY, $marks);
                 } else {
                     $part3 = strtr(_JLMS_RECURRENT_PAYMENT_MORE_DAYS, $marks);
                 }
                 $part3 .= "<br />";
             }
         }
     }
     $res = $part1 . $part2 . $part3 . $part4;
     return $res;
 }
Пример #3
0
    function ShowCart($option, &$subscriptions, &$lists, $procs = array())
    {
        global $Itemid, $JLMS_CONFIG, $JLMS_SESSION, $JLMS_DB, $my;
        $jlms_tax_counting = $JLMS_CONFIG->get('enabletax');
        $sub_total = 0;
        $tax_amount = 0;
        $rows2 = array();
        $custom_code = '';
        $discounts = array();
        $app =& JFactory::getApplication();
        $coupon_code = $app->getUserStateFromRequest('com_joomla_lms_dis_coupon_code', 'dis_coupon_code', '');
        $discounts['t_coupon_disc'] = JLMS_DISCOUNTS::getTotalCouponDiscount($coupon_code, $subscriptions);
        $discounts['t_disc'] = JLMS_DISCOUNTS::getTotalDiscounts($subscriptions);
        // counting taxes
        if ($jlms_tax_counting) {
            $is_cb_installed = $JLMS_CONFIG->get('is_cb_installed', 0);
            $get_country_info = $JLMS_CONFIG->get('get_country_info', 0);
            $cb_country_filed_id = intval($JLMS_CONFIG->get('jlms_cb_country'));
            $isset_country = false;
            if ($is_cb_installed && $get_country_info && $cb_country_filed_id) {
                //by Max (get country info)
                $query = "SELECT cf.name" . "\n FROM #__comprofiler_fields as cf" . "\n WHERE 1" . "\n AND cf.fieldid = '" . $cb_country_filed_id . "'";
                $JLMS_DB->setQuery($query);
                $cb_country_field_name = $JLMS_DB->loadResult();
                $query = "SELECT " . $cb_country_field_name . "" . "\n FROM #__comprofiler" . "\n WHERE 1" . "\n AND user_id = '" . $my->id . "'";
                $JLMS_DB->setQuery($query);
                $country_name = $JLMS_DB->loadResult();
                require_once 'components' . DS . $option . DS . 'includes' . DS . 'libraries' . DS . 'lms.lib.countries.php';
                $CodeCountry = new CodeCountries();
                $code = $CodeCountry->code($country_name);
                if ($code) {
                    $user_country = $code;
                }
                $user_country_name = '';
                $us_state = '';
            } else {
                $ip_address = $_SERVER['REMOTE_ADDR'];
                //$ip_address = '213.184.248.211';
                //				$ip_address = '12.225.42.19';
                //				$ip_address = '111.215.41.12';
                if (@ini_get('allow_url_fopen')) {
                    $fn = @file('http://api.hostip.info/get_html.php?ip=' . $ip_address);
                    // country ip identified
                    if ($fn != false) {
                        $ip_info = implode('', $fn);
                        preg_match_all("(\\(..\\))", $ip_info, $dop);
                        $user_country = str_replace('(', '', str_replace(")", '', $dop[0][0]));
                        preg_match_all("(\\:.*\\()", $ip_info, $dop2);
                        $user_country_name = str_replace(': ', '', str_replace(" (", '', $dop2[0][0]));
                        preg_match_all("(\\, ..)", $ip_info, $dop3);
                        $us_state = @str_replace(', ', '', $dop3[0][0]);
                    }
                }
            }
            if (isset($user_country)) {
                $query = "SELECT * FROM #__lms_subscriptions_countries WHERE published = 1 AND code='" . $user_country . "' ";
                $JLMS_DB->setQuery($query);
                $rows2 = $JLMS_DB->loadObjectList();
                // if no country found
                if (!count($rows2)) {
                    // check if in EU
                    $query = "SELECT * FROM #__lms_subscriptions_countries WHERE published = 1 AND code='EU' AND list REGEXP '" . $user_country . "' ";
                    $JLMS_DB->setQuery($query);
                    $rows_eu = $JLMS_DB->loadObjectList();
                    if (count($rows_eu)) {
                        $isset_country = true;
                        $rows2[0]->tax_type = $rows_eu[0]->tax_type;
                        $rows2[0]->tax = $rows_eu[0]->tax;
                        $user_country_name = $rows_eu[0]->name . ' (' . $user_country_name . ')';
                    }
                } else {
                    $isset_country = true;
                }
                // additional check for US
                if ($user_country == 'US') {
                    $query = "SELECT * FROM #__lms_subscriptions_countries WHERE published = 1 AND code = 'US-" . $us_state . "' ";
                    $JLMS_DB->setQuery($query);
                    $rows_states = $JLMS_DB->loadObjectList();
                    if (count($rows_states)) {
                        $isset_country = true;
                        $rows2 = array();
                        $rows2[0]->tax_type = $rows_states[0]->tax_type;
                        $rows2[0]->tax = $rows_states[0]->tax;
                        $user_country_name = 'United states (' . $rows_states[0]->name . ' )';
                    }
                }
            }
            //10.01.09 (Max) default tax option
            if (!$isset_country) {
                $rows2[0]->tax_type = $JLMS_CONFIG->get('default_tax_type', 1);
                $rows2[0]->tax = $JLMS_CONFIG->get('default_tax', 0);
            }
        }
        ?>
		<script language="javascript" type="text/javascript">
		<!--
		function jq_Check_selectCheckbox(check_name, form_name) {
			selItem = eval("document."+form_name+"['"+check_name+"']");
			if (selItem) {
				if (selItem.length) { var i;
					for (i = 0; i<selItem.length; i++) {
						if (selItem[i].checked) {
							if (selItem[i].value) { return true; }
						}}
				} else if (selItem.checked) { return true; }}
			return false;
		}
		function jlms_submitbutton(pressbutton) {
			var form = document.JLMS_adminForm;
			if( pressbutton == 'remove_from_cart' ){
				var ttt = jq_Check_selectCheckbox('jlms_sub[]', 'JLMS_adminForm');
				if (ttt) {
					form.task.value = pressbutton;
					form.submit();
				} else {
					alert("<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
");
				}
			}
			if( pressbutton == 'update_cart' ){
					form.task.value = pressbutton;
					form.submit();
			}
			if (pressbutton == 'cart_login') {
				form.task.value = pressbutton;
				form.submit();
			}
			
			if (pressbutton == 'apply_coupon_code') {
				form.task.value = pressbutton;
				form.submit();
			}
		}
		//-->
		</script>	

		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}");
        ?>
" method="post" name="JLMS_adminForm">
		<input type="hidden" value="<?php 
        echo $option;
        ?>
" name="option">
		<input type="hidden" value="<?php 
        echo $Itemid;
        ?>
" name="Itemid">
		<input type="hidden" value="" name="task">
		<input type="hidden" value="" name="id">
		<?php 
        JLMS_TMPL::OpenMT();
        $params = array('show_menu' => true, 'simple_menu' => true);
        JLMS_TMPL::ShowHeader('cart', _JLMS_MY_CART, $params);
        JLMS_TMPL::ShowPageTip('show_cart');
        JLMS_TMPL::CloseMT();
        $count_subs = count($subscriptions);
        ?>
		<br />
		<?php 
        if ($count_subs > 0) {
            ?>
		
		<input type="text" name="dis_coupon_code" value="<?php 
            echo $coupon_code;
            ?>
" />&nbsp;
		<input type="button" value="Check coupon" onclick="jlms_submitbutton('apply_coupon_code');" />
		<?php 
        }
        ?>
	
		<table cellpadding="0" cellspacing="0" border="0" width="100%" class="jlms_cart_list_outer" style="width:100%">
		<?php 
        if ($count_subs > 0) {
            ?>
			<tr>
				<td>
				<?php 
            $need_upd_txt = false;
            for ($i = 0, $n = count($subscriptions); $i < $n; $i++) {
                if (isset($subscriptions[$i]->allow_multiple) && $subscriptions[$i]->allow_multiple) {
                    $need_upd_txt = true;
                    break;
                }
            }
            $jlms_cs = $JLMS_CONFIG->get('jlms_cur_sign');
            $total_subs = 0;
            $total_disc = 0;
            $total_tax = 0;
            $discounts['total_p_disc'] = 0;
            $reccSubId = false;
            for ($i = 0, $n = count($subscriptions); $i < $n; $i++) {
                JLMS_CART_html::initSubscriptionPaymentParams($subscriptions[$i], $rows2);
                if ($subscriptions[$i]->account_type == '6') {
                    $reccSubId = $i;
                }
                if (isset($subscriptions[$i]->count_items) && $subscriptions[$i]->count_items && isset($subscriptions[$i]->allow_multiple) && $subscriptions[$i]->allow_multiple) {
                    $total_subs += $subscriptions[$i]->sub_total * $subscriptions[$i]->count_items;
                    $total_tax += $subscriptions[$i]->tax_amount * $subscriptions[$i]->count_items;
                    $total_disc += $subscriptions[$i]->disc * $subscriptions[$i]->count_items;
                } else {
                    $total_subs += $subscriptions[$i]->sub_total;
                    $total_tax += $subscriptions[$i]->tax_amount;
                    $total_disc += $subscriptions[$i]->disc;
                }
                if ($subscriptions[$i]->p_coupon_disc || $subscriptions[$i]->p_disc) {
                    $params['showDiscount'] = true;
                }
            }
            if (isset($rows2[0]->tax_type) && $rows2[0]->tax_type == 2) {
                $total_tax += $rows2[0]->tax;
                // if tx is not in percentage....
            }
            $discounts['total_p_disc'] = $total_disc;
            $total_disc = $total_disc + ($discounts['t_coupon_disc'] + $discounts['t_disc']);
            $total_price = $total_subs - $total_disc;
            if ($total_price < 0) {
                $total_price = $total_tax;
            } else {
                $total_price += $total_tax;
            }
            $price_diff = $total_subs - $total_disc;
            if ($price_diff < 0) {
                $balance = abs($price_diff);
            } else {
                $balance = 0;
            }
            $recurr_total_desc = '';
            if ($reccSubId !== false) {
                $price = JLMS_RECURRENT_PAY::getPriceDesc($subscriptions[$reccSubId], 'basket_list', $balance, $total_price);
                $recurr_total_desc = JLMS_RECURRENT_PAY::getPriceDesc($subscriptions[$reccSubId], 'total', $balance, $total_price);
                if ($total_price == 0) {
                    $total_price = JLMS_RECURRENT_PAY::getAmountFromReccurentPrice($subscriptions[$reccSubId]);
                }
            }
            ?>

					<div style="float:right; padding-top:5px; padding-right:25px">
						<b><?php 
            echo _JLMS_SUBSCR_SUB_TOTAL . ' ' . $jlms_cs . sprintf('%.2f', round($total_price, 2));
            ?>
</b>
					</div>
				</td>
			</tr>
			<tr>
				<td>
				<?php 
            if ($need_upd_txt) {
                ?>
				<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
					<tr>
					<td><div style="float:right; text-align:center"><?php 
                echo _JLMS_CART_HAVE_CHANGED_QUANTITY;
                ?>
<a href="javascript:jlms_submitbutton('update_cart');"><?php 
                echo _JLMS_CART_UPDATE;
                ?>
</a></div></td>
					</tr>
				</table>
				<?php 
            }
            ?>

<?php 
            $do_show_index = false;
            for ($i = 0, $n = count($subscriptions); $i < $n; $i++) {
                $subscription = $subscriptions[$i];
                $s = 1;
                foreach ($subscription->course_names as $course_name) {
                    $course_usertype = 0;
                    if (in_array($subscription->courses[$s - 1], $JLMS_CONFIG->get('teacher_in_courses', array(0)))) {
                        $course_usertype = 1;
                    } elseif (in_array($subscription->courses[$s - 1], $JLMS_CONFIG->get('student_in_courses', array(0)))) {
                        $course_usertype = 2;
                    }
                    if ($course_usertype) {
                        $do_show_index = true;
                        break;
                    }
                    $s++;
                }
                if ($do_show_index) {
                    break;
                }
            }
            ?>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist', 'jlms_cart_list');
            ?>
">
					<tr>
						<?php 
            if ($do_show_index) {
                ?>
<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" align="center" width="16">#</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
><?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="left" width="20">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="left"><?php 
            echo _JLMS_SUBSCRIBE_SUB_COURSES;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="left"><?php 
            echo _JLMS_DETAILS;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center" width="170"><?php 
            echo _JLMS_COURSES_PRICE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>						
						<?php 
            if (isset($params['showDiscount']) && $params['showDiscount']) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" align="center" width="40" nowrap="nowrap"><?php 
                echo _JLMS_CART_DISCOUNT;
                ?>
</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<?php 
            }
            if (isset($rows2[0]) && $rows2[0]->tax_type == 1 && $rows2[0]->tax) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" align="center" width="40" nowrap="nowrap"><?php 
                echo _JLMS_CART_TAX;
                ?>
</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center" width="40" nowrap="nowrap"><?php 
            echo _JLMS_CART_QUANTITY;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					</tr>
				<?php 
            for ($i = 0, $n = count($subscriptions); $i < $n; $i++) {
                $subscription = $subscriptions[$i];
                $tax_amount = 0;
                $disc = 0;
                if ($subscription->account_type != '6') {
                    $price = $jlms_cs . sprintf('%.2f', round($subscriptions[$i]->sub_total, 2));
                }
                $price_sub = $price;
                $custom_code .= JLMS_CART_html::ShowSub($subscription, $i + 1, '', $price_sub, $do_show_index, false, $params);
            }
            ?>
				</table>
				</td>
			</tr>
			<tr>
				<td>
					<div style="float:right; padding-top:5px; padding-right:25px; text-align:right;">
						<?php 
            if ($total_tax || $total_disc) {
                echo '<b>' . $jlms_cs . sprintf('%.2f', round($total_subs, 2)) . '</b><br />';
                if ($total_disc) {
                    echo '<b>' . _JLMS_SUBSCR_DISCOUNT_AMOUNT . ' ' . $jlms_cs . sprintf('%.2f', round($total_disc, 2)) . '</b><br />';
                }
                if ($total_tax) {
                    echo '<b>' . _JLMS_SUBSCR_TAX_AMOUNT . ' ' . $jlms_cs . sprintf('%.2f', round($total_tax, 2)) . '</b><br />';
                }
            }
            echo '<b>' . _JLMS_SUBSCR_SUB_TOTAL . ' ' . $jlms_cs . sprintf('%.2f', round($total_price, 2)) . '</b><br />';
            echo '<b>' . $recurr_total_desc . '</b>';
            ?>
					</div>
				</td>
			</tr>
<?php 
            $controls = array();
            if ($JLMS_CONFIG->get('under_ssl') && $JLMS_CONFIG->get('real_live_site')) {
                $temp_href = $JLMS_CONFIG->get('real_live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=subscription";
            } else {
                $temp_href = $JLMS_CONFIG->get('live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=subscription";
            }
            $controls[] = array('href' => $temp_href, 'title' => _JLMS_CART_BACK_TO_SHOP, 'img' => 'back');
            $controls[] = array('href' => "javascript:jlms_submitbutton('remove_from_cart');", 'title' => _JLMS_CART_REMOVE, 'img' => 'cartremove');
            JLMS_TMPL::ShowControlsFooter($controls, '', false);
            ?>
		</table>
<?php 
            if ($my->id && !empty($procs)) {
                JLMS_TMPL::OpenMT('jlms_table_no_borders');
                JLMS_TMPL::OpenTS();
                $sub_proc = $JLMS_SESSION->get('sub_proc');
                if (isset($_COOKIE['proc_id'])) {
                    $sub_proc = $_COOKIE['proc_id'];
                }
                $temp2 = "";
                foreach ($procs as $proc) {
                    $checked = '';
                    if (count($procs) == 1) {
                        $temp2 = "checkProcessor('" . $proc->id . "','" . $proc->filename . "');";
                        $checked = 'checked="checked"';
                    }
                    if ($sub_proc) {
                        if ($sub_proc == $proc->id) {
                            $temp2 = "checkProcessor('" . $proc->id . "','" . $proc->filename . "');";
                            $checked = 'checked="checked"';
                        }
                    } else {
                        if ($proc->default_p) {
                            $temp2 = "checkProcessor('" . $proc->id . "','" . $proc->filename . "');";
                            $checked = 'checked="checked"';
                        }
                    }
                    echo '<input type="radio" name="proc_id" value="' . $proc->id . '" onclick="checkProcessor(\'' . $proc->id . '\',\'' . $proc->filename . '\');" id="proc_' . $proc->id . '" ' . $checked . ' />&nbsp;<label class="msspro_sel_proc2" for="proc_' . $proc->id . '">' . $proc->name . '</label><br />';
                }
                if ($temp2) {
                    echo '<script type="text/javascript" language="javascript"><!--' . "\r\n";
                    echo $temp2;
                    echo "\r\n--></script>";
                }
                JLMS_TMPL::CloseTS();
                JLMS_TMPL::CloseMT();
            }
            ?>
	
	<?php 
            echo "</form>";
            if (!$my->id) {
                JLMS_UserSessions_html::loginPanel();
            }
        } else {
            echo "<tr><td><div class='joomlalms_sys_message'>";
            echo _JLMS_CART_IS_EMPTY;
            echo '<br />';
            if ($JLMS_CONFIG->get('under_ssl') && $JLMS_CONFIG->get('real_live_site')) {
                $temp_href = $JLMS_CONFIG->get('real_live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=subscription";
            } else {
                $temp_href = $JLMS_CONFIG->get('live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=subscription";
            }
            echo '<a href="' . $temp_href . '" title="' . _JLMS_CART_BACK_TO_SHOP . '">[' . _JLMS_CART_BACK_TO_SHOP . ']</a>';
            echo "</div></td></tr></table>";
            echo "</form>";
        }
        return $custom_code;
    }
Пример #4
0
    function show_checkout($option, $subscription, $item_id, $proc)
    {
        global $Itemid, $JLMS_CONFIG, $JLMS_DB;
        $params = new JLMSParameters($proc->params);
        if (!$params->get('server_url') || !$params->get('business_email')) {
            $redirect_task = 'subscription';
            if ($subscription->payment_type == 2) {
                $redirect_task = 'show_cart';
            }
            JLMSredirect(sefRelToAbs("index.php?option=" . $option . "&Itemid=" . $Itemid . "&task={$redirect_task}"), "This payment method is not available at the moment.<br /> Ask site administrator to check payment method settings.");
        }
        //setcookie('joomlalms_cart_contents', '', time()-3600, '/');
        JLMSCookie::setcookie('joomlalms_cart_contents', '$current_cart_cookie', time() - 3600, '/');
        global $JLMS_DB;
        $subscr_ids = implode(',', $subscription->subscriptions);
        if (!$subscription->sub_name && count($subscription->subscriptions) && (strpos($params->get('item_name'), '[sub]') !== false || strpos($params->get('item_name'), '[SUB]') !== false)) {
            $query = "SELECT id, sub_name FROM #__lms_subscriptions WHERE id IN ({$subscr_ids})";
            $JLMS_DB->SetQuery($query);
            $subs_names_list_db = $JLMS_DB->LoadObjectList();
            //create item name from list of all subscriptions separated by comma, ordered as in cart
            $subs_names_list = array();
            foreach ($subscription->subscriptions as $cart_sub_id) {
                foreach ($subs_names_list_db as $subname_item) {
                    if ($subname_item->id == $cart_sub_id) {
                        $subs_names_list[] = $subname_item->sub_name;
                        break;
                    }
                }
            }
            $subscription->sub_name = implode(', ', $subs_names_list);
        }
        if ($subscription->payment_type) {
            $query = "SELECT course_id FROM #__lms_subscriptions_courses WHERE sub_id IN (" . $subscr_ids . ")";
            $JLMS_DB->SetQuery($query);
            $courses = $JLMS_DB->LoadResultArray();
        } else {
            $courses = array();
        }
        $where = '';
        $whereacc = '';
        $where .= " AND ps.subscr_id IN (" . $subscr_ids . ")";
        $query = "SELECT p.id, p.name, p.description, p.published, p.p1, p.t1, p.p2, p.t2, p.p3, p.t3, s.a1, s.a2, s.a3, p.sra, p.src, p.srt, p.params" . "\n FROM #__lms_plans_subscriptions ps, #__lms_plans p, #__lms_subscriptions s" . "\n WHERE s.id=ps.subscr_id AND ps.plan_id=p.id AND s.account_type=6" . $where;
        $JLMS_DB->setQuery($query);
        $plan = $JLMS_DB->loadObject();
        if (is_object($plan)) {
            $plan->tax = $subscription->tax;
            $plan->tax_type = $subscription->tax_type;
            JLMS_RECURRENT_PAY::initPricesObjects($plan);
        }
        //check if there is subscription with account_type==4
        $whereacc .= " AND s.id IN (" . $subscr_ids . ")";
        $query = "SELECT s.id, s.access_days" . "\n FROM #__lms_subscriptions s" . "\n WHERE s.account_type=4" . $whereacc;
        $JLMS_DB->setQuery($query);
        $subscriptionAccesses = $JLMS_DB->loadObjectList();
        $adddays = 0;
        if ($subscriptionAccesses) {
            foreach ($subscriptionAccesses as $subscr) {
                $adddays += $subscr->access_days;
            }
        }
        //get user_id
        $query = "SELECT user_id FROM #__lms_payments WHERE id=" . $item_id;
        $JLMS_DB->setQuery($query);
        $uid = $JLMS_DB->loadResult();
        ?>
	<html>	
  	<head>
  		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
  	</head>
	<body onLoad="document.forms.jlms_checkout_form.submit();">
<?php 
        $print_item_name = $params->get('item_name');
        if (strpos($print_item_name, '[sub]') !== false || strpos($print_item_name, '[SUB]') !== false) {
            //compare and repalce both uppercase and lowercase strings (stri_repalce not used for PHP4 compat)
            $print_item_name = str_replace('[sub]', $subscription->sub_name, $print_item_name);
            $print_item_name = str_replace('[SUB]', $subscription->sub_name, $print_item_name);
        }
        if (!$print_item_name) {
            $print_item_name = $subscription->sub_name;
        }
        if (!is_object($plan)) {
            ?>
	<form action="<?php 
            echo $params->get('server_url');
            ?>
" method="post" name="jlms_checkout_form" id="jlms_checkout_form" />
	<input type="hidden" name="cmd" value="_xclick" />
	<input type="hidden" name="business" value="<?php 
            echo $params->get('business_email');
            ?>
" />
	<input type="hidden" name="on0" value="Tax amount" />
	<input type="hidden" name="os0" value="<?php 
            echo $subscription->tax_amount;
            ?>
" />
	<input type="hidden" name="item_number" value="<?php 
            echo $item_id;
            ?>
" />
	<input type="hidden" name="item_name" value="<?php 
            echo $print_item_name;
            ?>
" />
	<input type="hidden" name="no_shipping" value="1" />
<?php 
            if (count($courses) == 1 && $subscription->payment_type == 0) {
                ?>
	<input type="hidden" name="return" value="<?php 
                echo JURI::root();
                ?>
index.php?option=<?php 
                echo $option;
                ?>
&Itemid=<?php 
                echo $Itemid;
                ?>
&task=details_course&id=<?php 
                echo $courses[0];
                ?>
" />
<?php 
            } else {
                ?>

	<input type="hidden" name="return" value="<?php 
                echo JURI::root();
                ?>
index.php?option=<?php 
                echo $option;
                ?>
&Itemid=<?php 
                echo $Itemid;
                ?>
" />
<?php 
                /*
                	<input type="hidden" name="return" value="<?php echo $JLMS_CONFIG->get('live_site');?>/index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id?>&proc=<?php echo $proc->id;?>" />
                */
            }
            ?>
	<input type="hidden" name="rm" value="2" />
	<input type="hidden" name="cancel_return" value="<?php 
            if ($params->get('cancel_url') == '') {
                echo sefRelToAbs("index.php?option=com_joomla_lms&Itemid=" . $Itemid);
            } else {
                echo $params->get('cancel_url');
            }
            ?>
">
	<input type="hidden" name="notify_url" value="<?php 
            echo JURI::root();
            ?>
index.php?option=com_joomla_lms&task=callback&trs_id=<?php 
            echo $item_id;
            ?>
&proc=<?php 
            echo $proc->id;
            ?>
" />
	<input type="hidden" name="amount" value="<?php 
            echo number_format($subscription->price + $subscription->tax_amount, 2, '.', '');
            ?>
" />
	<input type="hidden" name="currency_code" value="<?php 
            echo $JLMS_CONFIG->get('jlms_cur_code');
            ?>
" />
	<input type="hidden" name="receiver_email" value="<?php 
            echo $params->get('business_email');
            ?>
" />
	<input type="hidden" name="charset" value="utf-8" />
	</form>
<?php 
        } else {
            if ($subscription->recurrent_obj) {
                $plan = $subscription->recurrent_obj;
            }
            ?>
	<form action="<?php 
            echo $params->get('server_url');
            ?>
" method="post" name="jlms_checkout_form" id="jlms_checkout_form">
	<input type="hidden" name="cmd" value="_xclick-subscriptions" />
	<input type="hidden" name="business" value="<?php 
            echo $params->get('business_email');
            ?>
" />
	<input type="hidden" name="item_name" value="<?php 
            echo $print_item_name;
            ?>
" />
	<input type="hidden" name="item_number" value="<?php 
            echo $item_id;
            ?>
" />	
	<input type="hidden" name="no_shipping" value="1" />	
	<input type="hidden" name="rm" value="2" />
	<input type="hidden" name="no_note" value="1" />	
	<input type="hidden" name="currency_code" value="<?php 
            echo $JLMS_CONFIG->get('jlms_cur_code');
            ?>
" />	
	<?php 
            if (count($courses) == 1 && $subscription->payment_type == 0) {
                ?>
	<input type="hidden" name="return" value="<?php 
                echo JURI::root();
                ?>
index.php?option=<?php 
                echo $option;
                ?>
&Itemid=<?php 
                echo $Itemid;
                ?>
&task=details_course&id=<?php 
                echo $courses[0];
                ?>
" />
	<?php 
            } else {
                ?>

	<input type="hidden" name="return" value="<?php 
                echo JURI::root();
                ?>
index.php?option=<?php 
                echo $option;
                ?>
&Itemid=<?php 
                echo $Itemid;
                ?>
" />
	<?php 
                /*
                	<input type="hidden" name="return" value="<?php echo $JLMS_CONFIG->get('live_site');?>/index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id?>&proc=<?php echo $proc->id;?>" />
                */
                ?>
	<?php 
            }
            ?>
	
	<input type="hidden" name="cancel_return" value="<?php 
            if ($params->get('cancel_url') == '') {
                echo sefRelToAbs("index.php?option=com_joomla_lms&Itemid=" . $Itemid);
            } else {
                echo $params->get('cancel_url');
            }
            ?>
" />
	<input type="hidden" name="notify_url" value="<?php 
            echo JURI::root();
            ?>
index.php?option=com_joomla_lms&task=callback&trs_id=<?php 
            echo $item_id;
            ?>
&proc=<?php 
            echo $proc->id;
            ?>
&subscr=1" />
	<?php 
            //if is basic then no other parameters should be considered
            if ($plan->price1->showPrice() || $plan->price1->isPeriodTrial()) {
                ?>
		<input type="hidden" name="a1" value="<?php 
                echo $plan->price1->get('a');
                ?>
"/>
		<input type="hidden" name="p1" value="<?php 
                echo $plan->price1->get('p');
                ?>
"/>
		<input type="hidden" name="t1" value="<?php 
                echo $plan->t1;
                ?>
"/>
		<?php 
            }
            if ($plan->price2->showPrice()) {
                ?>
		<input type="hidden" name="a2" value="<?php 
                echo $plan->price2->get('a');
                ?>
"/>
		<input type="hidden" name="p2" value="<?php 
                echo $plan->price2->get('p');
                ?>
"/>
		<input type="hidden" name="t2" value="<?php 
                echo $plan->t2;
                ?>
"/>
		<?php 
            }
            ?>
		<input type="hidden" name="a3" value="<?php 
            echo $plan->price3->get('a');
            ?>
"/>
		<input type="hidden" name="p3" value="<?php 
            echo $plan->price3->get('p');
            ?>
"/>
		<input type="hidden" name="t3" value="<?php 
            echo $plan->t3;
            ?>
"/>
	<?php 
            if ($plan->src && $plan->price3->get('srt') != 1) {
                ?>
		<input type="hidden" name="srt" value="<?php 
                echo $plan->price3->get('srt');
                ?>
"/>
		<input type="hidden" name="src" value="<?php 
                echo $plan->src;
                ?>
"/>
		<input type="hidden" name="sra" value="<?php 
                echo $plan->sra;
                ?>
">
	<?php 
            }
            ?>
	
	<input type="hidden" name="charset" value="utf-8" />
	</form>	
	<?php 
        }
        ?>
	<?php 
        /*<br /><br /><br /><br /><br /><br />
        	<center>
        	<img class="JLMS_png" src="<?php echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('lms_path_to_images', 'components/com_joomla_lms/lms_images');?>/loading.gif" width="32" height="32" border="0" alt="..." title="..." />
        	</center> */
        ?>
	</body>
	</html>
	<?php 
        die;
    }