Avatar billede phpnoob Novice
20. januar 2016 - 10:35 Der er 33 kommentarer

telefonummer 8 tal kun!

håber der nogen programmøre der kan hjælpe mig her jeg har denne her form hvor jeg i telefonummer vil gøre så man kun kan skrive 8 tal så folk ikke kommer til at skrive + 45 mellerum også

jeg har den her chekout.php som her sådan her ud

<br /><div class='sanitized'><pre class='sanitized'> <br /> <div class="container-fluid">
    <div class="panel panel-default pjAsContainer">
        <?php
        if (isset($tpl['status']) && $tpl['status'] == 'OK')
        {
            $FORM = @$_SESSION[$controller->defaultForm];
            $cart = $tpl['cart'];
            $cart_arr = $tpl['cart_arr'];
            end($cart);
            $key = key($cart);
            reset($cart);
           
            list($cid, $date, $service_id, $start_ts, $end_ts, $employee_id) = explode("|", $key);
            list($year, $month, $day) = explode("-", $date);
           
            $back_url = '';
            ?>
            <div class="panel-heading pjAsHead">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <?php
                        $slug = NULL;
                        if($_GET['layout'] == '1')
                        {
                            if ((int) $tpl['option_arr']['o_seo_url'] === 1)
                            {
                                $slug = sprintf("%s/%s/%s/%s/%s-%u/%s-%u.html", 'Employee', $year, $month, $day, pjAppController::friendlyURL($cart_arr[$service_id]['employee_arr'][$employee_id]['name']), $employee_id, pjAppController::friendlyURL($cart_arr[$service_id]['name']), $service_id);
                            }
                            $back_url = '<a href="#" class="btn btn-default pjAsBtn pjAsBtnSecondary pjAsBackToEmployee" data-iso="'.$date.'" data-eid="'.$employee_id.'" data-sid="'.$service_id.'" data-slug="'.$slug.'">' . __('btnCancel', true) . '</a>';
                            ?>
                            <a href="#" class="btn btn-link pjAsBtnBack pjAsBackToEmployee" data-iso="<?php echo $date;?>" data-eid="<?php echo $employee_id; ?>" data-sid="<?php echo $service_id; ?>" data-slug="<?php echo $slug;?>">
                                <i class="fa fa-angle-double-left"></i> <?php __('front_back');?>
                            </a>
                            <?php
                        }else{   
                            if ((int) $tpl['option_arr']['o_seo_url'] === 1)
                            {
                                $slug = sprintf("%s/%s/%s/%s/%s-%u/%s-%u.html", 'Service', $year, $month, $day, pjAppController::friendlyURL($cart_arr[$service_id]['name']), $service_id, pjAppController::friendlyURL($cart_arr[$service_id]['employee_arr'][$employee_id]['name']), $employee_id);
                            }
                            $back_url = '<a href="#" class="btn btn-default pjAsBtn pjAsBtnSecondary pjAsBackToService" data-iso="'.$date.'" data-eid="'.$employee_id.'" data-sid="'.$service_id.'" data-slug="'.$slug.'">' . __('btnCancel', true) . '</a>';
                            ?>
                            <a href="#" class="btn btn-link pjAsBtnBack pjAsBackToService" data-iso="<?php echo $date;?>" data-eid="<?php echo $employee_id; ?>" data-sid="<?php echo $service_id; ?>" data-slug="<?php echo $slug;?>">
                                <i class="fa fa-angle-double-left"></i> <?php __('front_back');?>
                            </a>
                            <?php
                        }
                        ?>
                    </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
                </div><!-- /.row -->
            </div><!-- /.panel-heading pjAsHead -->
           
            <?php include PJ_VIEWS_PATH . 'pjFrontPublic/elements/cart.php';  ?>
           
            <div class="panel-body pjAsBody pjAsCheckout">
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('single_price');?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['price'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_tax');?> (<?php echo $tpl['option_arr']['o_tax'];?>%)</h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['tax'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_total');?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['total'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_deposit');?><?php echo $tpl['option_arr']['o_deposit_type'] == 'percent' ? ' ('.$tpl['option_arr']['o_deposit'].'%)' : NULL;?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['deposit'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
               
                <h3 class="text-uppercase pjAsSectionTitle"><?php __('front_booking_form');?>:</h3><!-- /.pull-left text-uppercase pjAsSectionTitle -->
               
                <div class="form-horizontal">
                    <form role="form" data-toggle="validator" method="post" action="" novalidate="true" class="asSelectorCheckoutForm">
                        <input type="hidden" name="as_checkout" value="1" />
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_name'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_name'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_name'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_name'] === 3 ? ' required' : NULL; ?>" name="c_name"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_name']); ?>" data-msg-required="<?php __('co_v_name', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_email'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_email'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_email'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control email<?php echo (int) $tpl['option_arr']['o_bf_email'] === 3 ? ' required' : NULL; ?>" name="c_email"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_email']); ?>" data-msg-required="<?php __('co_v_email', false, true); ?>" data-msg-email="<?php __('co_v_email_inv', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_phone'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_phone'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_phone'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_phone'] === 3 ? ' required' : NULL; ?>" name="c_phone"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_phone']); ?>" data-msg-required="<?php __('co_v_phone', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_address_1'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_address_1'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_address_1'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_address_1'] === 3 ? ' required' : NULL; ?>" name="c_address_1"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_address_1']); ?>" data-msg-required="<?php __('co_v_address_1', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_address_2'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_address_2'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_address_2'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_address_2'] === 3 ? ' required' : NULL; ?>" name="c_address_2"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_address_2']); ?>" data-msg-required="<?php __('co_v_address_2', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_country'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_country'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_country'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <select name="c_country_id" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_country'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('co_v_country', false, true); ?>">
                                    <option value="">-- <?php __('co_select_country'); ?> --</option>
                                    <?php
                                    foreach ($tpl['country_arr'] as $country)
                                    {
                                        ?><option value="<?php echo $country['id']; ?>"<?php echo $country['id'] != @$FORM['c_country_id'] ? NULL : ' selected="selected"'; ?>><?php echo pjSanitize::html($country['name']); ?></option><?php
                                    }
                                    ?>
                                </select>
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_state'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_state'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_state'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_state'] === 3 ? ' required' : NULL; ?>" name="c_state"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_state']); ?>" data-msg-required="<?php __('co_v_state', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_city'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_city'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_city'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_city'] === 3 ? ' required' : NULL; ?>" name="c_city"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_city']); ?>" data-msg-required="<?php __('co_v_city', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_zip'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_zip'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_zip'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_zip'] === 3 ? ' required' : NULL; ?>" name="c_zip"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_zip']); ?>" data-msg-required="<?php __('co_v_zip', false, true); ?>">
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_notes'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_notes'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_notes'] === 3) : ?><span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <textarea name="c_notes" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_notes'] === 3 ? ' required' : NULL; ?>" cols="30" rows="10" data-msg-required="<?php __('co_v_notes', false, true); ?>"><?php echo pjSanitize::html(@$FORM['c_notes']); ?></textarea>
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif;?>
                       
                        <?php if ((int) $tpl['option_arr']['o_disable_payments'] === 0 && !empty($tpl['option_arr']['o_deposit'])) : ?>
                       
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_payment_method'); ?>
                                <span class="asterisk">*</span>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <select name="payment_method" class="form-control required" data-msg-required="<?php __('co_v_payment', false, true); ?>">
                                    <option value="">-- <?php __('front_select_payment'); ?> --</option>
                                    <?php
                                    foreach (__('payment_methods', true) as $k => $v)
                                    {
                                        if ((int) $tpl['option_arr']['o_allow_' . $k] === 1)
                                        {
                                            ?><option value="<?php echo $k; ?>"<?php echo @$FORM['payment_method'] != $k ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
                                        }
                                    }
                                    ?>
                                </select>
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorBank" style="display: <?php echo @$FORM['payment_method'] != 'bank' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_bank_account'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <?php echo pjSanitize::html($tpl['option_arr']['o_bank_account']); ?>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_cc_type'); ?>
                                <span class="asterisk">*</span>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <select name="cc_type" class="form-control required" data-msg-required="<?php __('co_v_cc_type', false, true); ?>">
                                    <option value="">-- <?php __('front_select_cc_type'); ?> --</option>
                                    <?php
                                    foreach (__('booking_cc_types', true) as $k => $v)
                                    {
                                        ?><option value="<?php echo $k; ?>"<?php echo @$FORM['cc_type'] != $k ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
                                    }
                                    ?>
                                </select>
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_num'); ?> <span class="asterisk">*</span></label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input type="text" name="cc_num" class="form-control required" value="<?php echo pjSanitize::html(@$FORM['cc_num']); ?>" autocomplete="off" data-msg-required="<?php __('co_v_cc_num', false, true); ?>" />
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_code'); ?> <span class="asterisk">*</span></label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <input type="text" name="cc_code" class="form-control required" value="<?php echo pjSanitize::html(@$FORM['cc_code']); ?>" autocomplete="off" data-msg-required="<?php __('co_v_cc_code', false, true); ?>" />
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_exp'); ?> <span class="asterisk">*</span></label>
                           
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <div class="row">
                                    <?php
                                    $time = pjTime::factory()
                                        ->attr('name', 'cc_exp_month')
                                        ->attr('id', 'cc_exp_month_' . $_GET['cid'])
                                        ->attr('class', 'form-control')
                                        ->prop('format', 'F');
               
                                    if (isset($FORM['cc_exp_month']))
                                    {
                                        $time->prop('selected', $FORM['cc_exp_month']);
                                    }
                                    ?>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-sx-12">
                                        <?php echo $time->month();?>
                                    </div>
                                    <?php
                                    $time = pjTime::factory()
                                        ->attr('name', 'cc_exp_year')
                                        ->attr('id', 'cc_exp_year_' . $_GET['cid'])
                                        ->attr('class', 'form-control')
                                        ->prop('left', 0)
                                        ->prop('right', 6);
                                       
                                    if (isset($FORM['cc_exp_year']))
                                    {
                                        $time->prop('selected', $FORM['cc_exp_year']);
                                    }
                                    ?>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-sx-12">
                                        <?php echo $time->year();?>
                                    </div>
                                </div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_captcha'], array(3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('co_captcha'); ?>
                                <?php if ((int) $tpl['option_arr']['o_bf_captcha'] === 3) : ?> <span class="asterisk">*</span><?php endif; ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <div class="row">
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-sx-12">
                                        <input type="text" name="captcha" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_captcha'] === 3 ? ' asRequired' : NULL; ?>" maxlength="6" autocomplete="off" data-msg-required="<?php __('co_v_captcha', false, true); ?>" data-msg-remote="<?php __('co_v_captcha_remote', false, true); ?>" />
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-sx-12">
                                        <img alt="Captcha" src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFrontEnd&action=pjActionCaptcha&rand=<?php echo rand(1000, 999999); ?>" style="vertical-align: middle" />
                                    </div>
                                </div>
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_terms'], array(3))) : ?>
                        <div class="form-group">
                            <div class="col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12">
                                <div class="checkbox">
                                    <label for="terms_<?php echo $_GET['cid']; ?>">
                                        <input id="terms_<?php echo $_GET['cid']; ?>" name="terms" class="<?php echo (int) $tpl['option_arr']['o_bf_terms'] === 3 ? 'required' : NULL; ?>" data-msg-required="<?php __('co_v_terms', false, true); ?>" type="checkbox">
                                        <?php __('co_terms'); ?>
                                    </label>

                                    <div class="help-block with-errors"></div>
                                </div><!-- /.checkbox -->
                                <div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
                            </div><!-- /.col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php
                        if (isset($tpl['terms_arr']) && !empty($tpl['terms_arr']))
                        {
                            $t_url = $tpl['terms_arr']['terms_url'];
                            $t_body = trim($tpl['terms_arr']['terms_body']);
                            ?>
                            <div class="form-group">
                                <div class="col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12">
                                   
                                    <?php
                                    if (!empty($t_url) && preg_match('/^http(s)?:\/\//i', $t_url))
                                    {
                                        ?><a href="<?php echo pjSanitize::html($t_url); ?>" target="_blank"><?php __('front_terms_link'); ?></a><?php
                                    } elseif (!empty($t_body)) {
                                        ?><a href="#" data-target="#asTermModal" data-toggle="modal"><?php __('front_terms_link'); ?></a><?php
                                    }
                                    ?>
                                   
                                </div><!-- /.col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12 -->
                            </div><!-- /.form-group -->   
                            <?php
                        }
                        ?>
                        <?php endif; ?>
                       
                        <div class="form-group">
                            <div class="col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12">
                                <input style="pointer-events: all; cursor: pointer;" class="btn btn-default pjAsBtn pjAsBtnPrimary" value="<?php __('btnContinue', false, true); ?>" type="submit"<?php echo count($cart) == 0 ? ' disabled="disabled"' : null;?>>
                                <?php echo $back_url;?>
                            </div><!-- /.col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12 -->
                        </div><!-- /.form-group -->
                    </form>
                   
                    <div class="modal fade pjTbModal" id="asTermModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                          <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-body">
                                    <?php echo nl2br(pjSanitize::clean($t_body));?>
                                </div>
                                  <div class="modal-footer">
                                    <button type="button" class="btn btn-default pjTbBtn pjTbBtnPrimary" data-dismiss="modal"><?php __('front_close');?></button>
                                  </div>
                            </div>
                          </div>
                    </div>
                </div><!-- /.form-horizontal -->
            </div><!-- /.panel-body pjAsBody pjAsCheckout -->
            <?php
        } elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') {
            ?>
            <div class="panel-heading pjAsHead">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="alert alert-warning" role="alert">
                              <?php __('front_system_msg'); ?><br/><?php __('front_checkout_na'); ?> <a href="#" class="alert-link pjAsBtnBackToServices"><?php __('front_return_back');?></a>
                        </div>
                    </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
                </div><!-- /.row -->
            </div><!-- /.panel-heading pjAsHead -->
            <?php
        }
        ?>
    </div><!-- /.panel panel-default pjAsContainer -->
</div> </b><br /></pre></div>/div>
                               


også har jeg en anden som hedder actionpreview..
<br /><div class='sanitized'><pre class='sanitized'> <br /> <div class="container-fluid">
    <div class="panel panel-default pjAsContainer">
        <?php
        if (isset($tpl['status']) && $tpl['status'] == 'OK')
        {
            $FORM = @$_SESSION[$controller->defaultForm];
            $cart = $tpl['cart'];
            $cart_arr = $tpl['cart_arr'];
            end($cart);
            $key = key($cart);
            reset($cart);
           
            list($cid, $date, $service_id, $start_ts, $end_ts, $employee_id) = explode("|", $key);
           
            $back_url = '';
            ?>
            <div class="panel-heading pjAsHead">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <a href="#" class="btn btn-link pjAsBtnBack pjAsBtnBackToCheckout" data-eid="<?php echo $employee_id; ?>" data-sid="<?php echo $service_id; ?>" data-slug="<?php echo $slug;?>">
                            <i class="fa fa-angle-double-left"></i> <?php __('front_back');?>
                        </a>
                    </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
                </div><!-- /.row -->
            </div><!-- /.panel-heading pjAsHead -->
           
            <?php include PJ_VIEWS_PATH . 'pjFrontPublic/elements/cart.php';  ?>
           
            <div class="panel-body pjAsBody pjAsCheckout">
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('single_price');?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['price'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_tax');?> (<?php echo $tpl['option_arr']['o_tax'];?>%)</h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['tax'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_total');?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['total'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
                <div class="clearfix">
                    <h3 class="pull-left text-uppercase pjAsSectionTotal"><?php __('front_deposit');?><?php echo $tpl['option_arr']['o_deposit_type'] == 'percent' ? ' ('.$tpl['option_arr']['o_deposit'].'%)' : NULL;?></h3><!-- /.pull-left text-uppercase pjAsSectionTotal -->

                    <h3 class="pull-right text-uppercase pjAsSectionPrice">
                        <strong><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['deposit'], 2), $tpl['option_arr']['o_currency']);?></strong>
                    </h3><!-- /.pull-right text-uppercase pjAsSectionPrice -->
                </div><!-- /.clearfix -->
               
                <h3 class="text-uppercase pjAsSectionTitle"><?php __('front_preview_form');?>:</h3><!-- /.pull-left text-uppercase pjAsSectionTitle -->
               
                <div class="form-horizontal">
                    <form role="form" data-toggle="validator" method="post" action="" novalidate="true" class="asSelectorPreviewForm">
                        <input type="hidden" name="as_preview" value="1" />
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_name'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_name'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_name']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_email'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_email'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_email']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_phone'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_phone'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_phone']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_address_1'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_address_1'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_address_1']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_address_2'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_address_2'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_address_2']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_country'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_country'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$tpl['country_arr']['name']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_state'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_state'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">   
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_state']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_city'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_city'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_city']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_zip'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_zip'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['c_zip']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if (in_array((int) $tpl['option_arr']['o_bf_notes'], array(2,3))) : ?>
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_notes'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo nl2br(pjSanitize::html(@$FORM['c_notes'])); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <?php if ((int) $tpl['option_arr']['o_disable_payments'] === 0 && !empty($tpl['option_arr']['o_deposit'])) : ?>
                       
                        <div class="form-group">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_payment_method'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <?php
                                $pm = __('payment_methods', true);
                                ?>
                                <p class="form-control-static"><?php echo @$pm[$FORM['payment_method']]; ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorBank" style="display: <?php echo @$FORM['payment_method'] != 'bank' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_bank_account'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <?php echo pjSanitize::html($tpl['option_arr']['o_bank_account']); ?>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize">
                                <?php __('booking_cc_type'); ?>
                            </label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <?php
                                $ct = __('booking_cc_types', true);
                                ?>
                                <p class="form-control-static"><?php echo @$ct[$FORM['cc_type']]; ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                       
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_num'); ?></label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['cc_num']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_code'); ?></label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php echo pjSanitize::html(@$FORM['cc_code']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <div class="form-group asSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
                            <label for="" class="col-lg-3 col-md-3 col-sm-3 col-sx-12 control-label text-capitalize"><?php __('booking_cc_exp'); ?></label>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-sx-12">
                                <p class="form-control-static"><?php printf("%s/%s", $FORM['cc_exp_month'], $FORM['cc_exp_year']); ?></p>
                            </div><!-- /.col-lg-9 col-md-9 col-sm-9 col-sx-12 -->
                        </div><!-- /.form-group -->
                        <?php endif; ?>
                       
                        <div class="alert alert-warning asSelectorError" role="alert" style="display: none"></div>
                       
                        <div class="form-group">
                            <div class="col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12">
                                <input style="pointer-events: all; cursor: pointer;" class="btn btn-default pjAsBtn pjAsBtnPrimary" value="<?php __('front_confirm_booking', false, true); ?>" type="submit"<?php echo count($cart) == 0 ? ' disabled="disabled"' : null;?>>
                                <a href="#" class="btn btn-default pjAsBtn pjAsBtnSecondary pjAsBtnBackToCheckout"><?php __('btnCancel', false, true); ?></a>
                            </div><!-- /.col-lg-9 col-lg-offset-3 col-md-9 col-md-offset-3 col-sm-9 col-sm-offset-3 col-sx-12 -->
                        </div><!-- /.form-group -->
                    </form>
                </div><!-- /.form-horizontal -->
            </div><!-- /.panel-body pjAsBody pjAsCheckout -->
            <?php
        } elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') {
            ?>
            <div class="panel-heading pjAsHead">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="alert alert-warning" role="alert">
                              <?php __('front_system_msg'); ?><br/><?php __('front_checkout_na'); ?> <a href="#" class="alert-link pjAsBtnBackToServices"><?php __('front_return_back');?></a>
                        </div>
                    </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
                </div><!-- /.row -->
            </div><!-- /.panel-heading pjAsHead -->
            <?php
        }
        ?>
    </div><!-- /.panel panel-default pjAsContainer -->
</div> </b><br /></pre></div>/div>
                                   

grunden til at jeg skriver begge filer det er så man bedre kan forstå samenhængen og bedre hjælpe mig.

Hvis man kigger i begge filer så ingår der en funktion der hedder pjsantize filen kommer her(jeg tænker måske man kan indsætte en ekstra funktion i den file så der tilgår telefonfeltet kan man det og hvordan?? skal det sættes i et array og hvordan skriver jeg funktionen ind i filen så det virker? kan det lade sig gøre eller skal man ud i javascript validering?? det bare den nemmest løsning til det her telefonfelt som folk bliver ved med at skrive forkert i så smsgateawayen som jeg har i systemet den går i koks fordi den finder selv ud af at den kun skal og kan sende til danske telefonnumre..

pjsantize filen:   
<?php
/**
* Washes strings from unwanted noise. Helpful methods to make unsafe strings usable.
*
* @package framework.components
*/

/**
* Data Sanitization.
*
* Removal of alphanumeric characters, HTML-friendly strings,
* and all of the above on arrays.
*
*/
class pjSanitize
{
/**
* Sanitizes given array or value for safe input. Use the options to specify
* what filters should be applied (with a boolean value). Valid filters:
*
* - odd_spaces - removes any non space whitespace characters
* - encode - Encode any html entities. Encode must be true for the `remove_html` to work.
* - dollar - Escape `$` with `\$`
* - carriage - Remove `\r`
* - unicode -
* - backslash -
* - remove_html - Strip HTML with strip_tags. `encode` must be true for this option to work.
*
* @param string|array $data Data to sanitize
* @param string|array $options Set of options
* @return mixed Sanitized data
*/
    public static function clean($data, $options = array())
    {
        if (empty($data)) {
            return $data;
        }

        $options = array_merge(array(
            'odd_spaces' => true,
            'remove_html' => false,
            'encode' => true,
            'dollar' => true,
            'carriage' => true,
            'unicode' => true,
            'backslash' => true
        ), $options);

        if (is_array($data)) {
            foreach ($data as $key => $val) {
                $data[$key] = pjSanitize::clean($val, $options);
            }
            return $data;
        }

        if ($options['odd_spaces']) {
            $data = str_replace(chr(0xCA), '', $data);
        }
        if ($options['encode']) {
            $data = pjSanitize::html($data, array('remove' => $options['remove_html']));
        }
        if ($options['dollar']) {
            $data = str_replace("\\\$", "$", $data);
        }
        if ($options['carriage']) {
            $data = str_replace("\r", "", $data);
        }
        if ($options['unicode']) {
            $data = preg_replace("/&#([0-9]+);/s", "&#\\1;", $data);
        }
        if ($options['backslash']) {
            $data = preg_replace("/\\\(?!&#|\?#)/", "\\", $data);
        }
        return $data;
    }
/**
* Returns given string safe for display as HTML. Renders entities.
*
* strip_tags() does not validating HTML syntax or structure, so it might strip whole passages
* with broken HTML.
*
* ### Options:
*
* - remove (boolean) if true strips all HTML tags before encoding
* - charset (string) the charset used to encode the string
* - quotes (int) see http://php.net/manual/en/function.htmlentities.php
* - double (boolean) doube encode html entities
*
* @param string $string String from where to strip tags
* @param array $options Array of options to use.
* @static
* @access public
* @return string Sanitized string
*/
    public static function html($string, $options = array())
    {
        $default = array(
            'remove' => false,
            'charset' => 'UTF-8',
            'quotes' => ENT_QUOTES,
            'double' => true
        );

        $options = array_merge($default, $options);

        if ($options['remove'])
        {
            $string = strip_tags($string);
        }

        return htmlentities($string, $options['quotes'], $options['charset'], $options['double']);
    }
/**
* Removes any non-alphanumeric characters.
*
* @param string $string String to sanitize
* @param array $allowed An array of additional characters that are not to be removed.
* @static
* @access public
* @return string Sanitized string
*/
    public static function paranoid($string, $allowed = array())
    {
        $allow = null;
        if (!empty($allowed))
        {
            foreach ($allowed as $value)
            {
                $allow .= "\\$value";
            }
        }

        if (!is_array($string))
        {
            return preg_replace("/[^{$allow}a-zA-Z0-9]/", '', $string);
        }

        $cleaned = array();
        foreach ($string as $key => $clean)
        {
            $cleaned[$key] = preg_replace("/[^{$allow}a-zA-Z0-9]/", '', $clean);
        }

        return $cleaned;
    }
/**
* Strips extra whitespace, images, scripts and stylesheets from output
*
* @param string $str String to sanitize
* @static
* @access public
* @return string sanitized string
*/
    public static function stripAll($str)
    {
        return pjSanitize::stripScripts(
            pjSanitize::stripImages(
                pjSanitize::stripWhitespace($str)
            )
        );
    }
/**
* Strips image tags from output
*
* @param string $str String to sanitize
* @static
* @access public
* @return string Sting with images stripped.
*/
    public static function stripImages($str)
    {
        $preg = array(
            '/(<a[^>]*>)(<img[^>]+alt=")([^"]*)("[^>]*>)(<\/a>)/i' => '$1$3$5<br />',
            '/(<img[^>]+alt=")([^"]*)("[^>]*>)/i' => '$2<br />',
            '/<img[^>]*>/i' => ''
        );

        return preg_replace(array_keys($preg), array_values($preg), $str);
    }
/**
* Strips scripts and stylesheets from output
*
* @param string $str String to sanitize
* @static
* @access public
<br /><div class='sanitized'><pre class='sanitized'> <br />
* @return string String with <link>, <img>, <script>, <style> elements and html comments removed.
*/
    public static function stripScripts($str)
    {
        $regex =
            '/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|' .
            '<img[^>]*>|style="[^"]*")|' .
            '<script[^>]*>.*?<\/script>|' .
            '<style[^>]*>.*?<\/style>|' .
            '<!--.*?-->/is';
       
        return preg_replace($regex, '', $str);
    }
/**
* Strips the specified tags from output. First parameter is string from
* where to remove tags. All subsequent parameters are tags.
*
* Ex.`$clean = pjSanitize::stripTags($dirty, 'b', 'p', 'div');`
*
* Will remove all `<b>`, `<p>`, and `<div>` tags from the $dirty string.
*
* @param string $str,... String to sanitize
* @static
* @access public
* @return string sanitized String
*/
    public static function stripTags($str)
    {
        $params = func_get_args();

        for ($i = 1, $count = count($params); $i < $count; $i++)
        {
            $str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str);
            $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str);
        }
        return $str;
    }
/**
* Strips extra whitespace from output
*
* @param string $str String to sanitize
* @static
* @access public
* @return string whitespace sanitized string
*/
    public static function stripWhitespace($str)
    {
        return preg_replace('/\s{2,}/u', ' ', preg_replace('/[\n\r\t]+/', '', $str));
    }
}
?>
</div> </b><br /></pre></div>/div>
Avatar billede phpnoob Novice
20. januar 2016 - 10:36 #1
og selvfølig kunne jeg ikke indramme den i kode bokse
Avatar billede phpnoob Novice
20. januar 2016 - 10:44 #2
og forresten der hvor telefonummer er er den som hedder c_phone
Avatar billede moddi100 Seniormester
20. januar 2016 - 18:31 #3
For at sætte en begrænsning på kun 8 tal, der kan indtastes (altså ikke rigtig validering), kan du gøre følgende:
// Udskift denne kode
<input class="form-control<?php echo (int) $tpl['option_arr']['o_bf_phone'] === 3 ? ' required' : NULL; ?>" name="c_phone"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_phone']); ?>" data-msg-required="<?php __('co_v_phone', false, true); ?>">

// Med denne kode
<input maxlength="8" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_phone'] === 3 ? ' required' : NULL; ?>" name="c_phone"  type="text" value="<?php echo pjSanitize::html(@$FORM['c_phone']); ?>" data-msg-required="<?php __('co_v_phone', false, true); ?>">


Til en anden gang, vil det være en fordel at du kun viser den relevante udsnit af din kode.
Derudover kan du anvende f.eks. http://www.pastebin.com til at kopiere koden ind, så den bliver mere læsevenlig.
Avatar billede phpnoob Novice
20. januar 2016 - 20:52 #4
tak moddi men det var ikke rigtigt det jeg søgte men det er bedre end ingenting :) jeg ville gerne havde lavet det sådan noget ala ligesom hvis man glemmer lave  skrive snabel feks . navn@email.dk så de fleste forme det findes ude på nettet opdager dettet og meddeler det så man ikke kan gå videre. håber du forstår
Avatar billede moddi100 Seniormester
20. januar 2016 - 21:12 #5
Nu snakker du om e-mail, var det ikke telefonnummer du havde problem med?
Avatar billede phpnoob Novice
20. januar 2016 - 21:17 #6
jo det er telefonnummeret jeg mener men det var bare et eksempel på hvad jeg mener jeg vil havde det skal ske med det telefonnummer..om man kan gøre det i php på en eller anden måde?
Avatar billede moddi100 Seniormester
20. januar 2016 - 21:31 #7
Du kan tilføje følgende funktion til din sanitize class:
public static function phone($string)
    {
      // Remove spaces
      $string = preg_replace("/\s/", "", $string);

      // Return the first available 8-digit combination
      if(preg_match("/(?:\+?45)?(\d{8})/", $string, $matches))
      {
          // We got a phone number
          return $matches[1];
      }

      return NULL; // No phone number, default value is returned
    }
Avatar billede phpnoob Novice
20. januar 2016 - 21:52 #8
okay skal jeg bare sætte den ind helt normalt i santize php component hvad skal jeg skrive noget i c_phone formen filen der hvor jeg skal bruge det eller finder den selv ud af det?
Avatar billede phpnoob Novice
20. januar 2016 - 22:05 #9
altså jeg tænker hvordan reagere min form så hvis det er forkert? altså hvis det ikke bliver skrevet 8 tal kun
Avatar billede phpnoob Novice
20. januar 2016 - 22:07 #10
og er det menningen der skal stå +45 i pregmath
Avatar billede moddi100 Seniormester
20. januar 2016 - 22:13 #11
Du skal blot udskifte alle forekomster af
pjSanitize::html(@$FORM['c_phone']);


Med
pjSanitize::phone(@$FORM['c_phone']);


Og ja, det skal stå sådan med +45, som det er skrevet.

Dog skal du have fundet det sted i koden, hvor c_phone gemmes. Men tilføjer du både #3 og dernæst #7, burde du være godt kørende i forhold til brugeren. Prøv det af!
Avatar billede moddi100 Seniormester
20. januar 2016 - 22:22 #12
#3 gør så der ikke kan skrives mere end 8 tal,

7# vil omdanne
+4512345678 => 12345678
124 347 12 => 12434712
+ 45 1 2 43 => [tom]
12493 => [tom]
Avatar billede phpnoob Novice
20. januar 2016 - 22:30 #13
prøver det med det samme
Avatar billede phpnoob Novice
20. januar 2016 - 22:54 #14
den omdanner den i preview til uden 45 det jo godt men når den gemmer så bliver den gemt igen som +45 ? kan du tjekke action booking hvad der skal ændre på forhånd tak :D :D

<?php
if (isset($tpl['status']) && $tpl['status'] == "OK")
{
    ?>
    <div class="panel-heading pjAsHead">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="alert alert-warning" role="alert">
                    <?php __('front_system_msg'); ?><br/>
                    <?php
                    $status = __('front_booking_status', true);
                    if (isset($tpl['booking_arr']))
                    {
                        switch ($tpl['booking_arr']['payment_method'])
                        {
                            case 'paypal':
                                switch ($tpl['invoice_arr']['status'])
                                {
                                    case 'not_paid':
                               
                                        echo $status[11];
                                        ?>
                                        <div class="asElementOutline"><?php
                                        if (pjObject::getPlugin('pjPaypal') !== NULL)
                                        {
                                            $controller->requestAction(array('controller' => 'pjPaypal', 'action' => 'pjActionForm', 'params' => $tpl['params']));
                                        }
                                        ?></div><?php
                                        break;
                                    case 'cancelled':
                                        echo $status[5];
                                        break;
                                    default:
                                        echo $status[3];
                                        break;
                                }
                                break;
                            case 'authorize':
                                switch ($tpl['invoice_arr']['status'])
                                {
                                    case 'not_paid':
                                        echo $status[11];
                                        ?>
                                        <div class="asElementOutline"><?php
                                        if (pjObject::getPlugin('pjAuthorize') !== NULL)
                                        {
                                            $controller->requestAction(array('controller' => 'pjAuthorize', 'action' => 'pjActionForm', 'params' => $tpl['params']));
                                        }
                                        ?></div><?php
                                        break;
                                    case 'cancelled':
                                        echo $status[5];
                                        break;
                                    default:
                                        echo $status[3];
                                        break;
                                }
                                break;
                            case 'bank':
                                echo $status[1] . '<br/>' .  pjSanitize::html(nl2br($tpl['option_arr']['o_bank_account']));
                                ?><br/><a href="#" class="alert-link pjAsBtnBackToServices"><?php __('front_start_over');?></a><?php
                                break;
                            case 'creditcard':
                            case 'none':
                            default:
                                echo $status[1];
                                ?><br/><a href="#" class="alert-link pjAsBtnBackToServices"><?php __('front_start_over');?></a><?php
                        }
                    } else {
                        echo $status[4];
                    }
                    ?>
                </div>
            </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
        </div>
    </div>
    <?php
} elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') {
    ?>
    <div class="panel-heading pjAsHead">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="alert alert-warning" role="alert">
                      <?php __('front_system_msg'); ?><br/><?php __('front_checkout_na'); ?><br/><a href="#" class="alert-link pjAsBtnBackToServices"><?php __('front_return_back');?></a>
                </div>
            </div><!-- /.col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
        </div><!-- /.row -->
    </div><!-- /.panel-heading pjAsHead -->
    <?php
}
?>
Avatar billede phpnoob Novice
20. januar 2016 - 23:11 #15
jeg prøver finde ud af hvor den gemmer den i mysql databasen henne det køre med mvc framework hvor burde det være???
Avatar billede moddi100 Seniormester
21. januar 2016 - 00:09 #16
Du skal ikke ændre i databasen, men blot finde stedet (ikke i den sidste kode, du postede), hvor c_phone gemmes.

Desuden så brug nu http://www.pastebin.com til at vise kode med. Ellers bliver den her tråd totalt overfyldt med ulæselig kode!
Avatar billede phpnoob Novice
21. januar 2016 - 00:15 #17
ja jeg prøver finde det men det bliver jo gemt i mysqldatabasen jeg går udfra det er det du mener... jeg er ny i oop php så ved jeg ved ikke hvor jeg skal lede jeg prøver kigge igen imorgen måske du har nogen råd hvor jeg skal kigge
Avatar billede moddi100 Seniormester
21. januar 2016 - 00:44 #18
Jeg ved ikke lige præcist hvilken fil det er, du har ikke oplyst noget som helst om hvilket system det kommer fra?

Led efter en fil, der hedder noget i stil med "actions.php", der er IKKE tale om et sted i databasen. Du har sikkert flere filer, der hedder noget i denne stil, vælg derfor den fil, der ligger tættest på ovenstående filer - dvs. den mappe der er tættest på.

Hvis du har en editor, der kan søge igennem alle filer på én gang, så find teksten pjSanitize::html(@$FORM['c_phone'])
Avatar billede phpnoob Novice
21. januar 2016 - 09:43 #19
jeg har med totalcomander søgt hele scriptet igennem og det fremgår kun i de to første filer som jeg har skrevet actioncheakout.php samt action preview .php det system jeg bruger er phpjabbers appoinment scheduler du kan se hvordan de koder inde på deres side hvis det kan hjælpe dig med at finde det sted de gemmer?? forstår ikke helt hvad det er du mener med gemmer fordi tingene bliver jo gemt i datasen tak
Avatar billede phpnoob Novice
21. januar 2016 - 12:04 #20
Alle booking data skulle blive gemt her

<?php
if (!defined("ROOT_PATH"))
{
    header("HTTP/1.1 403 Forbidden");
    exit;
}
class pjBookingModel extends pjAppModel
{
    protected $primaryKey = 'id';

    protected $table = 'bookings';

    protected $schema = array(
        array('name' => 'id', 'type' => 'int', 'default' => ':NULL'),
        array('name' => 'uuid', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'calendar_id', 'type' => 'int', 'default' => ':NULL'),
        array('name' => 'booking_price', 'type' => 'decimal', 'default' => ':NULL'),
        array('name' => 'booking_total', 'type' => 'decimal', 'default' => ':NULL'),
        array('name' => 'booking_deposit', 'type' => 'decimal', 'default' => ':NULL'),
        array('name' => 'booking_tax', 'type' => 'decimal', 'default' => ':NULL'),
        array('name' => 'booking_status', 'type' => 'enum', 'default' => ':NULL'),
        array('name' => 'payment_method', 'type' => 'enum', 'default' => ':NULL'),
        array('name' => 'c_name', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_email', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_phone', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_country_id', 'type' => 'int', 'default' => ':NULL'),
        array('name' => 'c_city', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_state', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_zip', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_address_1', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_address_2', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'c_notes', 'type' => 'text', 'default' => ':NULL'),
        array('name' => 'cc_type', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'cc_num', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'cc_exp_year', 'type' => 'year', 'default' => ':NULL'),
        array('name' => 'cc_exp_month', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'cc_code', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'txn_id', 'type' => 'varchar', 'default' => ':NULL'),
        array('name' => 'processed_on', 'type' => 'datetime', 'default' => ':NULL'),
        array('name' => 'created', 'type' => 'datetime', 'default' => ':NOW()'),
        array('name' => 'locale_id', 'type' => 'tinyint', 'default' => ':NULL'),
        array('name' => 'ip', 'type' => 'varchar', 'default' => ':NULL')
    );
   
    protected $validate = array(
        'rules' => array(
            'uuid' => array(
                'pjActionAlphaNumeric' => true,
                'pjActionNotEmpty' => true,
                'pjActionRequired' => true
            ),
            'calendar_id' => array(
                'pjActionNumeric' => true,
                'pjActionRequired' => true
            )
        )
    );

    public static function factory($attr=array())
    {
        return new pjBookingModel($attr);
    }
}
?>
Avatar billede phpnoob Novice
21. januar 2016 - 12:10 #21
Også fandt jeg det her
<?php
/**
* Validation Class.  Used for validation of model data
*
* @package      framework.components
* @since 1.0.0
*/
class pjValidation {

/**
* Some complex patterns needed in multiple places
*
* @var array
*/
    protected static $_pattern = array(
        'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
    );

/**
* Holds an array of errors messages set in this class.
* These are used for debugging purposes
*
* @var array
*/
    public static $errors = array();

/**
* Checks that a string contains something other than whitespace
*
* Returns true if string contains something other than whitespace
*
* $check can be passed as an array:
* array('check' => 'valueToCheck');
*
* @param mixed $check Value to check
* @return boolean Success
*/
    public static function pjActionNotEmpty($check) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (empty($check) && $check != '0') {
            return false;
        }
        return self::pjActionCheck($check, '/[^\s]+/m');
    }

/**
* Checks that a string contains only integer or letters
*
* Returns true if string contains only integer or letters
*
* $check can be passed as an array:
* array('check' => 'valueToCheck');
*
* @param mixed $check Value to check
* @return boolean Success
*/
    public static function pjActionAlphaNumeric($check) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (empty($check) && $check != '0') {
            return false;
        }
        return self::pjActionCheck($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu');
    }

/**
* Checks that a string length is within s specified range.
* Spaces are included in the character count.
* Returns true is string matches value min, max, or between min and max,
*
* @param string $check Value to check for length
* @param integer $min Minimum value in range (inclusive)
* @param integer $max Maximum value in range (inclusive)
* @return boolean Success
*/
    public static function pjActionBetween($check, $min, $max) {
        $length = mb_strlen($check);
        return ($length >= $min && $length <= $max);
    }

/**
* Returns true if field is left blank -OR- only whitespace characters are present in it's value
* Whitespace characters include Space, Tab, Carriage Return, Newline
*
* $check can be passed as an array:
* array('check' => 'valueToCheck');
*
* @param mixed $check Value to check
* @return boolean Success
*/
    public static function pjActionBlank($check) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }
        return !self::pjActionCheck($check, '/[^\\s]/');
    }

/**
* Validation of credit card numbers.
* Returns true if $check is in the proper credit card format.
*
* @param mixed $check credit card number to validate
* @param mixed $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit cards
*    if an array is used only the values of the array are checked.
*    Example: array('amex', 'bankcard', 'maestro')
* @param boolean $deep set to true this will check the Luhn algorithm of the credit card.
* @param string $regex A custom regex can also be passed, this will be used instead of the defined regex values
* @return boolean Success
* @see Validation::pjActionLuhn()
*/
    public static function pjActionCreditCard($check, $type = 'fast', $deep = false, $regex = null) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        $check = str_replace(array('-', ' '), '', $check);
        if (mb_strlen($check) < 13) {
            return false;
        }

        if (!is_null($regex)) {
            if (self::pjActionCheck($check, $regex)) {
                return self::pjActionLuhn($check, $deep);
            }
        }
        $cards = array(
            'all' => array(
                'amex' => '/^3[4|7]\\d{13}$/',
                'bankcard' => '/^56(10\\d\\d|022[1-5])\\d{10}$/',
                'diners'  => '/^(?:3(0[0-5]|[68]\\d)\\d{11})|(?:5[1-5]\\d{14})$/',
                'disc'    => '/^(?:6011|650\\d)\\d{12}$/',
                'electron' => '/^(?:417500|4917\\d{2}|4913\\d{2})\\d{10}$/',
                'enroute'  => '/^2(?:014|149)\\d{11}$/',
                'jcb'      => '/^(3\\d{4}|2100|1800)\\d{11}$/',
                'maestro'  => '/^(?:5020|6\\d{3})\\d{12}$/',
                'mc'      => '/^5[1-5]\\d{14}$/',
                'solo'    => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
                'switch'  => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/',
                'visa'    => '/^4\\d{12}(\\d{3})?$/',
                'voyager'  => '/^8699[0-9]{11}$/'),
            'fast'  => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/');

        if (is_array($type)) {
            foreach ($type as $value) {
                $regex = $cards['all'][strtolower($value)];

                if (self::pjActionCheck($check, $regex)) {
                    return self::pjActionLuhn($check, $deep);
                }
            }
        } elseif ($type == 'all') {
            foreach ($cards['all'] as $value) {
                $regex = $value;

                if (self::pjActionCheck($check, $regex)) {
                    return self::pjActionLuhn($check, $deep);
                }
            }
        } else {
            $regex = $cards['fast'];

            if (self::pjActionCheck($check, $regex)) {
                return self::pjActionLuhn($check, $deep);
            }
        }
        return false;
    }

/**
* Used to compare 2 numeric values.
*
* @param mixed $check1 if string is passed for a string must also be passed for $check2
*    used as an array it must be passed as array('check1' => value, 'operator' => 'value', 'check2' -> value)
* @param string $operator Can be either a word or operand
*    is greater >, is less <, greater or equal >=
*    less or equal <=, is less <, equal to ==, not equal !=
* @param integer $check2 only needed if $check1 is a string
* @return boolean Success
*/
    public static function pjActionComparison($check1, $operator = null, $check2 = null) {
        if (is_array($check1)) {
            extract($check1, EXTR_OVERWRITE);
        }
        $operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '', strtolower($operator));

        switch ($operator) {
            case 'isgreater':
            case '>':
                if ($check1 > $check2) {
                    return true;
                }
                break;
            case 'isless':
            case '<':
                if ($check1 < $check2) {
                    return true;
                }
                break;
            case 'greaterorequal':
            case '>=':
                if ($check1 >= $check2) {
                    return true;
                }
                break;
            case 'lessorequal':
            case '<=':
                if ($check1 <= $check2) {
                    return true;
                }
                break;
            case 'equalto':
            case '==':
                if ($check1 == $check2) {
                    return true;
                }
                break;
            case 'notequal':
            case '!=':
                if ($check1 != $check2) {
                    return true;
                }
                break;
            default:
                self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()');
                break;
        }
        return false;
    }

/**
* Used when a custom regular expression is needed.
*
* @param mixed $check When used as a string, $regex must also be a valid regular expression.
*                                As and array: array('check' => value, 'regex' => 'valid regular expression')
* @param string $regex If $check is passed as a string, $regex must also be set to valid regular expression
* @return boolean Success
*/
    public static function pjActionCustom($check, $regex = null) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }
        if ($regex === null) {
            self::$errors[] = __d('cake_dev', 'You must define a regular expression for Validation::pjActionCustom()');
            return false;
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Date validation, determines if the string passed is a valid date.
* keys that expect full month, day and year will validate leap years
*
* @param string $check a valid date string
* @param mixed $format Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
*           Keys: dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash
*                 mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash
*                 ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash
*                 dMy 27 December 2006 or 27 Dec 2006
*                 Mdy December 27, 2006 or Dec 27, 2006 comma is optional
*                 My December 2006 or Dec 2006
*                 my 12/2006 separators can be a space, period, dash, forward slash
* @param string $regex If a custom regular expression is used this is the only validation that will occur.
* @return boolean Success
*/
    public static function pjActionDate($check, $format = 'ymd', $regex = null) {
        if (!is_null($regex)) {
            return self::pjActionCheck($check, $regex);
        }

        $regex['dmy'] = '%^(?:(?:31(\\/|-|\\.|\\x20)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.|\\x20)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.|\\x20)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.|\\x20)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
        $regex['mdy'] = '%^(?:(?:(?:0?[13578]|1[02])(\\/|-|\\.|\\x20)31)\\1|(?:(?:0?[13-9]|1[0-2])(\\/|-|\\.|\\x20)(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:0?2(\\/|-|\\.|\\x20)29\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.|\\x20)(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
        $regex['ymd'] = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
        $regex['dMy'] = '/^((31(?!\\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\\b|t)t?|Nov)(ember)?)))|((30|29)(?!\\ Feb(ruary)?))|(29(?=\\ Feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)\\ ((1[6-9]|[2-9]\\d)\\d{2})$/';
        $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep)(tember)?|(Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
        $regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
        $regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';

        $format = (is_array($format)) ? array_values($format) : array($format);
        foreach ($format as $key) {
            $regex = $regex[$key];

            if (self::pjActionCheck($check, $regex) === true) {
                return true;
            }
        }
        return false;
    }

/**
* Validates a datetime value
* All values matching the "date" core validation rule, and the "time" one will be valid
*
* @param array $check Value to check
* @param mixed $dateFormat Format of the date part
* Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
* ## Keys:
*
*    - dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash
*    - mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash
*    - ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash
*  - dMy 27 December 2006 or 27 Dec 2006
*    - Mdy December 27, 2006 or Dec 27, 2006 comma is optional
*    - My December 2006 or Dec 2006
*     - my 12/2006 separators can be a space, period, dash, forward slash
* @param string $regex Regex for the date part. If a custom regular expression is used this is the only validation that will occur.
* @return boolean True if the value is valid, false otherwise
* @see Validation::pjActionDate
* @see Validation::pjActionTime
*/
    public static function pjActionDatetime($check, $dateFormat = 'ymd', $regex = null) {
        $valid = false;
        $parts = explode(' ', $check);
        if (!empty($parts) && count($parts) > 1) {
            $time = array_pop($parts);
            $date = implode(' ', $parts);
            $valid = self::pjActionDate($date, $dateFormat, $regex) && self::pjActionTime($time);
        }
        return $valid;
    }

/**
* Time validation, determines if the string passed is a valid time.
* Validates time as 24hr (HH:MM) or am/pm ([H]H:MM[a|p]m)
* Does not allow/validate seconds.
*
* @param string $check a valid time string
* @return boolean Success
*/
    public static function pjActionTime($check) {
        return self::pjActionCheck($check, '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%');
    }

/**
* Boolean validation, determines if value passed is a boolean integer or true/false.
*
* @param string $check a valid boolean
* @return boolean Success
*/
    public static function pjActionBoolean($check) {
        $booleanList = array(0, 1, '0', '1', true, false);
        return in_array($check, $booleanList, true);
    }

/**
* Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float
* If no decimal point is found a false will be returned. Both the sign and exponent are optional.
*
* @param integer $check The value the test for decimal
* @param integer $places if set $check value must have exactly $places after the decimal point
* @param string $regex If a custom regular expression is used this is the only validation that will occur.
* @return boolean Success
*/
    public static function pjActionDecimal($check, $places = null, $regex = null) {
        if (is_null($regex)) {
            if (is_null($places)) {
                $regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
            } else {
                $regex = '/^[-+]?[0-9]*\\.{1}[0-9]{'.$places.'}$/';
            }
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Validates for an email address.
*
* Only uses getmxrr() checking for deep validation if PHP 5.3.0+ is used, or
* any PHP version on a non-windows distribution
*
* @param string $check Value to check
* @param boolean $deep Perform a deeper validation (if true), by also checking availability of host
* @param string $regex Regex to use (if none it will use built in regex)
* @return boolean Success
*/
    public static function pjActionEmail($check, $deep = false, $regex = null) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
        }
        $return = self::pjActionCheck($check, $regex);
        if ($deep === false || $deep === null) {
            return $return;
        }

        if ($return === true && preg_match('/@(' . self::$_pattern['hostname'] . ')$/i', $check, $regs)) {
            if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
                return true;
            }
            if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
                return true;
            }
            return is_array(gethostbynamel($regs[1]));
        }
        return false;
    }

/**
* Check that value is exactly $comparedTo.
*
* @param mixed $check Value to check
* @param mixed $comparedTo Value to compare
* @return boolean Success
*/
    public static function pjActionEqualTo($check, $comparedTo) {
        return ($check === $comparedTo);
    }

/**
* Check that value has a valid file extension.
*
* @param mixed $check Value to check
* @param array $extensions file extenstions to allow
* @return boolean Success
*/
    public static function pjActionExtension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
        if (is_array($check)) {
            return self::pjActionExtension(array_shift($check), $extensions);
        }
        $pathSegments = explode('.', $check);
        $extension = strtolower(array_pop($pathSegments));
        foreach ($extensions as $value) {
            if ($extension == strtolower($value)) {
                return true;
            }
        }
        return false;
    }

/**
* Validation of an IP address.
*
* @param string $check The string to test.
* @param string $type The IP Protocol version to validate against
* @return boolean Success
*/
    public static function pjActionIp($check, $type = 'both') {
        $type = strtolower($type);
        $flags = array();
        if ($type === 'ipv4' || $type === 'both') {
            $flags[] = FILTER_FLAG_IPV4;
        }
        if ($type === 'ipv6' || $type === 'both') {
            $flags[] = FILTER_FLAG_IPV6;
        }
        return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
    }

/**
* Checks whether the length of a string is greater or equal to a minimal length.
*
* @param string $check The string to test
* @param integer $min The minimal string length
* @return boolean Success
*/
    public static function pjActionMinLength($check, $min) {
        return mb_strlen($check) >= $min;
    }

/**
* Checks whether the length of a string is smaller or equal to a maximal length..
*
* @param string $check The string to test
* @param integer $max The maximal string length
* @return boolean Success
*/
    public static function pjActionMaxLength($check, $max) {
        return mb_strlen($check) <= $max;
    }

/**
* Checks that a value is a monetary amount.
*
* @param string $check Value to check
* @param string $symbolPosition Where symbol is located (left/right)
* @return boolean Success
*/
    public static function pjActionMoney($check, $symbolPosition = 'left') {
        $money = '(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?';
        if ($symbolPosition == 'right') {
            $regex = '/^' . $money . '(?<!\x{00a2})\p{Sc}?$/u';
        } else {
            $regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u';
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Validate a multiple select.
*
* Valid Options
*
* - in => provide a list of choices that selections must be made from
* - max => maximum number of non-zero choices that can be made
* - min => minimum number of non-zero choices that can be made
*
* @param mixed $check Value to check
* @param mixed $options Options for the check.
* @return boolean Success
*/
    public static function pjActionMultiple($check, $options = array()) {
        $defaults = array('in' => null, 'max' => null, 'min' => null);
        $options = array_merge($defaults, $options);
        $check = array_filter((array)$check);
        if (empty($check)) {
            return false;
        }
        if ($options['max'] && count($check) > $options['max']) {
            return false;
        }
        if ($options['min'] && count($check) < $options['min']) {
            return false;
        }
        if ($options['in'] && is_array($options['in'])) {
            foreach ($check as $val) {
                if (!in_array($val, $options['in'])) {
                    return false;
                }
            }
        }
        return true;
    }

/**
* Checks if a value is numeric.
*
* @param string $check Value to check
* @return boolean Success
*/
    public static function pjActionNumeric($check) {
        return is_numeric($check);
    }

/**
* Check that a value is a valid phone number.
*
* @param mixed $check Value to check (string or array)
* @param string $regex Regular expression to use
* @param string $country Country code (defaults to 'all')
* @return boolean Success
*/
    public static function pjActionPhone($check, $regex = null, $country = 'all') {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            switch ($country) {
                case 'us':
                case 'all':
                case 'can':
                // includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
                    $regex  = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
                break;
            }
        }
        if (empty($regex)) {
            return self::pjActionPass('phone', $check, $country);
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Checks that a given value is a valid postal code.
*
* @param mixed $check Value to check
* @param string $regex Regular expression to use
* @param string $country Country to use for formatting
* @return boolean Success
*/
    public static function pjActionPostal($check, $regex = null, $country = 'us') {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            switch ($country) {
                case 'uk':
                    $regex  = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
                    break;
                case 'ca':
                    $regex  = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]\\b\\z/i';
                    break;
                case 'it':
                case 'de':
                    $regex  = '/^[0-9]{5}$/i';
                    break;
                case 'be':
                    $regex  = '/^[1-9]{1}[0-9]{3}$/i';
                    break;
                case 'us':
                    $regex  = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
                    break;
            }
        }
        if (empty($regex)) {
            return self::pjActionPass('postal', $check, $country);
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Validate that a number is in specified range.
* if $lower and $upper are not set, will return true if
* $check is a legal finite on this platform
*
* @param string $check Value to check
* @param integer $lower Lower limit
* @param integer $upper Upper limit
* @return boolean Success
*/
    public static function pjActionRange($check, $lower = null, $upper = null) {
        if (!is_numeric($check)) {
            return false;
        }
        if (isset($lower) && isset($upper)) {
            return ($check > $lower && $check < $upper);
        }
        return is_finite($check);
    }

/**
* Checks that a value is a valid Social Security Number.
*
* @param mixed $check Value to check
* @param string $regex Regular expression to use
* @param string $country Country
* @return boolean Success
*/
    public static function pjActionSsn($check, $regex = null, $country = null) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            switch ($country) {
                case 'dk':
                    $regex  = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
                    break;
                case 'nl':
                    $regex  = '/\\A\\b[0-9]{9}\\b\\z/i';
                    break;
                case 'us':
                    $regex  = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
                    break;
            }
        }
        if (empty($regex)) {
            return self::pjActionPass('ssn', $check, $country);
        }
        return self::pjActionCheck($check, $regex);
    }

/**
* Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
*
* The regex checks for the following component parts:
*
* - a valid, optional, scheme
* - a valid ip address OR
*  a valid domain name as defined by section 2.3.1 of http://www.ietf.org/rfc/rfc1035.txt
*  with an optional port number
* - an optional valid path
* - an optional query string (get parameters)
* - an optional fragment (anchor tag)
*
* @param string $check Value to check
* @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
* @return boolean Success
*/
    public static function pjActionUrl($check, $strict = false) {
        self::pjActionPopulateIp();
        $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
        $regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
            '(?:' . self::$_pattern['IPv4'] . '|\[' . self::$_pattern['IPv6'] . '\]|' . self::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
            '(?:\/?|\/' . $validChars . '*)?' .
            '(?:\?' . $validChars . '*)?' .
            '(?:#' . $validChars . '*)?$/iu';
        return self::pjActionCheck($check, $regex);
    }

/**
* Checks if a value is in a given list.
*
* @param string $check Value to check
* @param array $list List to check against
* @return boolean Success
*/
    public static function pjActionInList($check, $list) {
        return in_array($check, $list);
    }

/**
* Runs an user-defined validation.
*
* @param mixed $check value that will be validated in user-defined methods.
* @param object $object class that holds validation method
* @param string $method class method name for validation to run
* @param array $args arguments to send to method
* @return mixed user-defined class class method returns
*/
    public static function pjActionUserDefined($check, $object, $method, $args = null) {
        return call_user_func_array(array($object, $method), array($check, $args));
    }

/**
* Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
*
* @param string $check Value to check
* @return boolean Success
*/
    public static function pjActionUuid($check) {
        $regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
        return self::pjActionCheck($check, $regex);
    }

/**
* Attempts to pass unhandled Validation locales to a class starting with $classPrefix
* and ending with Validation.  For example $classPrefix = 'nl', the class would be
* `NlValidation`.
*
* @param string $method The method to call on the other class.
* @param mixed $check The value to check or an array of parameters for the method to be called.
* @param string $classPrefix The prefix for the class to do the validation.
* @return mixed Return of Passed method, false on failure
*/
    protected static function pjActionPass($method, $check, $classPrefix) {
        $className = ucwords($classPrefix) . 'Validation';
        if (!class_exists($className)) {
            trigger_error(__d('cake_dev', 'Could not find %s class, unable to complete validation.', $className), E_USER_WARNING);
            return false;
        }
        if (!method_exists($className, $method)) {
            trigger_error(__d('cake_dev', 'Method %s does not exist on %s unable to complete validation.', $method, $className), E_USER_WARNING);
            return false;
        }
        $check = (array)$check;
        return call_user_func_array(array($className, $method), $check);
    }

/**
* Runs a regular expression match.
*
* @param mixed $check Value to check against the $regex expression
* @param string $regex Regular expression
* @return boolean Success of match
*/
    protected static function pjActionCheck($check, $regex) {
        if (preg_match($regex, $check)) {
            self::$errors[] = false;
            return true;
        } else {
            self::$errors[] = true;
            return false;
        }
    }

/**
* Get the values to use when value sent to validation method is
* an array.
*
* @param array $params Parameters sent to validation method
* @return void
*/
    protected static function pjActionDefaults($params) {
        self::pjActionReset();
        $defaults = array(
            'check' => null,
            'regex' => null,
            'country' => null,
            'deep' => false,
            'type' => null
        );
        $params = array_merge($defaults, $params);
        if ($params['country'] !== null) {
            $params['country'] = mb_strtolower($params['country']);
        }
        return $params;
    }

/**
* Luhn algorithm
*
* @param string|array $check
* @param boolean $deep
* @return boolean Success
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
*/
    public static function pjActionLuhn($check, $deep = false) {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }
        if ($deep !== true) {
            return true;
        }
        if ($check == 0) {
            return false;
        }
        $sum = 0;
        $length = strlen($check);

        for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
            $sum += $check[$position];
        }

        for ($position = ($length % 2); $position < $length; $position += 2) {
            $number = $check[$position] * 2;
            $sum += ($number < 10) ? $number : $number - 9;
        }

        return ($sum % 10 == 0);
    }

/**
* Lazily populate the IP address patterns used for validations
*
* @return void
*/
    protected static function pjActionPopulateIp() {
        if (!isset(self::$_pattern['IPv6'])) {
            $pattern  = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
            $pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
            $pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
            $pattern .= '(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)';
            $pattern .= '{4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
            $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}';
            $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|';
            $pattern .= '((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}';
            $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
            $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4})';
            $pattern .= '{0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)';
            $pattern .= '|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]';
            $pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
            $pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';

            self::$_pattern['IPv6'] = $pattern;
        }
        if (!isset(self::$_pattern['IPv4'])) {
            $pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
            self::$_pattern['IPv4'] = $pattern;
        }
    }

/**
* Reset internal variables for another validation run.
*
* @return void
*/
    protected static function pjActionReset() {
        self::$errors = array();
    }
   
    public static function pjActionRequired($check) {
        if (function_exists('mb_trim')) {
            $val = mb_trim($check);
        } else {
            $val = trim($check);
        }
        return function_exists('mb_strlen') ? mb_strlen($val) > 0 : strlen($val) > 0;
    }
/**
* Checks if a value is cyrillic.
*
* @param string $check Value to check
* @param string $regex Regex to use (if none it will use built in regex)
* @return boolean Success
*/
    public static function pjActionCyrillic($check, $regex = null)
    {
        if (is_null($regex))
        {
            $regex = '/^[\p{Cyrillic}\d\s\-\.\"\']+$/u';
        }
        return preg_match($regex, $check);
    }
/**
* Checks if a value is EGN.
*
* @param string $check Value to check
* @return boolean Success
*/
    public static function pjActionEgn($check)
    {
        if (!preg_match('/\d{10}/', $check))
        {
            return false;
        }
       
        $t = array(2, 4, 8, 5, 10, 9, 7, 3, 6);
        $arr = str_split($check);
        $sum = 0;
        for ($i = 0; $i < 9; ++$i)
        {
            if ((int) $arr[$i] != 0)
            {
                $sum += (int) $arr[$i] * $t[$i];
            }
        }
        return (int) $arr[9] == ($sum % 11) % 10;
    }
}
?
Avatar billede moddi100 Seniormester
21. januar 2016 - 19:29 #22
Udskift:
public static function pjActionPhone($check, $regex = null, $country = 'all') {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            switch ($country) {
                case 'us':
                case 'all':
                case 'can':
                // includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
                    $regex  = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
                break;
            }
        }
        if (empty($regex)) {
            return self::pjActionPass('phone', $check, $country);
        }
        return self::pjActionCheck($check, $regex);
    }


Til
public static function pjActionPhone($check, $regex = null, $country = 'dk') {
        if (is_array($check)) {
            extract(self::pjActionDefaults($check));
        }

        if (is_null($regex)) {
            switch ($country) {
                case 'dk':
                    $regex  = '/^(?:\+?45)?( ?[0-9]{2}){4}$/';
                    break;
                case 'us':
                case 'all':
                case 'can':
                // includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
                    $regex  = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
                break;
            }
        }
        if (empty($regex)) {
            return self::pjActionPass('phone', $check, $country);
        }
        return self::pjActionCheck($check, $regex);
    }
Avatar billede phpnoob Novice
21. januar 2016 - 20:14 #23
kan jeg nøjes med at kun at ændre den sidste fil du skrev eller skal pjsantize stadig stå med den funktion som jeg tilføjede ?? det bare fordi det stod nogen med ::html er bange hvis jeg sletter det at der opstår problemmer??
Avatar billede moddi100 Seniormester
21. januar 2016 - 20:32 #24
Du skal heller ikke slette ::html i sanitize, du skal blot TILFØJE den nye funktion fra #7

Hvis du kun ændre i den sidste fil, så vil brugeren ikke se at der gemmes noget andet end det indtastede. Men prøv at gøre som anvist i mit sidste indlæg, og så test det af.
Avatar billede phpnoob Novice
21. januar 2016 - 21:01 #25
jeg tænker bare på det i formen hvordan kan jeg skrive så den stadig tager fra html altså det du skrev jeg skulle udskifte til
pjSanitize::html(@$FORM['c_phone']);
kan jeg så skrive den inde i så html stadig er med
pjSanitize::html::Phone(@$FORM['c_phone']);
er det korrekt skrevet eller hvordan?
Avatar billede moddi100 Seniormester
21. januar 2016 - 21:21 #26
Nej, du skal udskifte til det jeg angav. html er blot navnet på funktionen, dvs. den fjerner html-koder. Jeg har så lavet en Phone-funktion, der går endnu mere specifikt ind, og siger at den kun skal tillade danske telefonnumre
Avatar billede phpnoob Novice
21. januar 2016 - 21:31 #27
hvorfor behøver den så fremgår i formen det forstår jeg ikke? når pjsantize er det? det er det som jeg ikke forstår kan du forklare mig det?? ... altså fjerner jet html i formen kan man så godt lave html tag eller ikke når det jo stadig står i pjsantize som at man ikke kan og hvorfor skal jeg så skrive phone hvis funktionen allerede står i pjsantize håber du gider uddybe det tak
Avatar billede moddi100 Seniormester
21. januar 2016 - 21:49 #28
Den eneste ændring #7 vil have indvirkning på, er feltet c_phone. Resten vil forblive som det er.

pjsanitize dækker blot over en række funktioner til brug for forskellige typer af input. Et telefonnummer må f.eks. ikke indeholde de samme tegn som en e-mail-adresse. Derfor har pjsanitize flere forskellige funktioner - og med #7 tilføjer vi nu en specifik type til telefonnumre.

Laver du ikke ændringen i #7 anvendes den generelle funktion kaldet "html" blot på telefonnumret. Denne funktion fjerner html fra inputtet. "html"-funktionen anvendes altså som standard, såfremt der ikke er specificeret en anden funktion/regel for den aktuelle type af input. Nu definerer vi så en ny regel - altså et telefonnummer.
Avatar billede phpnoob Novice
21. januar 2016 - 21:58 #29
jeg tester det nu,
Avatar billede phpnoob Novice
21. januar 2016 - 22:29 #30
efter at havde udskiftet stykket i  validation component også som du skrev så viser den stadig +4512345678 når den bliver gemt?
Avatar billede phpnoob Novice
21. januar 2016 - 22:47 #31
men jeg kan nok først teste det når den sender en sms har jeg ret??
Avatar billede phpnoob Novice
21. januar 2016 - 23:10 #32
nej virker ikke ved ikke hvordan og hvorfor den stadig gemmer den som det ?? hvad skal jeg kigge efter?? mm?
Avatar billede phpnoob Novice
22. januar 2016 - 18:24 #33
jeg fandt denne gider du kigge på den
<?php
if (!defined("ROOT_PATH"))
{
    header("HTTP/1.1 403 Forbidden");
    exit;
}
class pjAdminBookings extends pjAdmin
{
    public function pjActionCheckUID()
    {
        $this->setAjax(true);
   
        if ($this->isXHR())
        {
            if (!isset($_GET['uuid']) || empty($_GET['uuid']))
            {
                echo 'false';
                exit;
            }
            $pjBookingModel = pjBookingModel::factory()->where('t1.uuid', $_GET['uuid']);
            if (isset($_GET['id']) && (int) $_GET['id'] > 0)
            {
                $pjBookingModel->where('t1.id !=', $_GET['id']);
            }
            echo $pjBookingModel->findCount()->getData() == 0 ? 'true' : 'false';
        }
        exit;
    }
   
    public function pjActionCreate()
    {
        $this->checkLogin();
       
        if ($this->isAdmin())
        {
            if (isset($_POST['booking_create']))
            {
                $data = array();
                $data['calendar_id'] = $this->getForeignId();
                $data['locale_id'] = $this->getLocaleId();
                $data['ip'] = $_SERVER['REMOTE_ADDR'];
                if ($_POST['payment_method'] != "creditcard")
                {
                    $data['cc_type'] = ':NULL';
                    $data['cc_num'] = ':NULL';
                    $data['cc_code'] = ':NULL';
                    $data['cc_exp_year'] = ':NULL';
                    $data['cc_exp_month'] = ':NULL';
                }
                $id = pjBookingModel::factory(array_merge($_POST, $data))->insert()->getInsertId();
                if ($id !== false && (int) $id > 0)
                {
                    if (!empty($_POST['tmp_hash']))
                    {
                        pjBookingServiceModel::factory()
                            ->where('tmp_hash', $_POST['tmp_hash'])
                            ->modifyAll(array('booking_id' => $id, 'tmp_hash' => ':NULL'));
                    }
                    $err = 'ABK03';
                } else {
                    $err = 'ABK04';
                }
                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminBookings&action=pjActionIndex&err=$err");
            } else {
                $this->set('country_arr', pjCountryModel::factory()
                    ->select('t1.*, t2.content AS `name`')
                    ->join('pjMultiLang', "t2.model='pjCountry' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                    ->where('t1.status', 'T')
                    ->orderBy('`name` ASC')
                    ->findAll()->getData());
               
                $tmp_hash = md5(uniqid(rand(), true));
               
                if(isset($_GET['employee_id']) && isset($_GET['service_id']) && isset($_GET['start_ts']))
                {
                    $date = date('Y-m-d', $_GET['start_ts']);
                   
                    $service_arr = pjServiceModel::factory()->find($_GET['service_id'])->getData();
                       
                    $bs_id = pjBookingServiceModel::factory()->setAttributes(array(
                            'tmp_hash' => $tmp_hash,
                            'booking_id' => 0,
                            'service_id' => $_GET['service_id'],
                            'employee_id' => $_GET['employee_id'],
                            'date' => $date,
                            'start' => date("H:i:s", $_GET['start_ts']),
                            'start_ts' => $_GET['start_ts'],
                            'total' => @$service_arr['total'],
                            'price' => @$service_arr['price']
                    ))->insert()->getInsertId();
                       
                    if ($bs_id !== FALSE && (int) $bs_id > 0)
                    {
                        $this->set('bs_id', $bs_id);
                    }
                }
               
                $this->set('tmp_hash', $tmp_hash);               
                $this
                    ->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/')
                    ->appendJs('pjAdminBookings.js')
                    ->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true);
            }
        } else {
            $this->set('status', 2);
        }
    }
   
    public function pjActionDeleteBooking()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_GET['id']) && (int) $_GET['id'] > 0 && pjBookingModel::factory()->set('id', $_GET['id'])->erase()->getAffectedRows() == 1)
            {
                pjBookingServiceModel::factory()->where('booking_id', $_GET['id'])->eraseAll();
                pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => ''));
            }
            pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => ''));
        }
        exit;
    }
   
    public function pjActionDeleteBookingBulk()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_POST['record']) && !empty($_POST['record']))
            {
                pjBookingModel::factory()->whereIn('id', $_POST['record'])->eraseAll();
                pjBookingServiceModel::factory()->whereIn('booking_id', $_POST['record'])->eraseAll();
                pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => ''));
            }
            pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => ''));
        }
        exit;
    }
   
    public function pjActionExport()
    {
        $this->checkLogin();
   
        if ($this->isAdmin())
        {
            if(isset($_POST['bookings_export']))
            {
                $pjBookingModel = pjBookingModel::factory()
                    ->select('t1.*, t2.*, t3.total as service_length, t4.content as employee_name, t5.content as service_name')
                    ->join('pjBookingService', 't2.booking_id=t1.id', 'left outer')
                    ->join('pjService', 't2.service_id=t3.id', 'left outer')
                    ->join('pjMultiLang', "t4.model='pjEmployee' AND t4.foreign_id=t2.employee_id AND t4.field='name' AND t4.locale='".$this->getLocaleId()."'", 'left outer')
                    ->join('pjMultiLang', "t5.model='pjService' AND t5.foreign_id=t2.service_id AND t5.field='name' AND t5.locale='".$this->getLocaleId()."'", 'left outer');
                   
                if($_POST['period'] == 'next')
                {
                    $column = 't2.date';
                    $direction = 'ASC';
   
                    $where_str = pjUtil::getComingWhere($_POST['coming_period'], $this->option_arr['o_week_start']);
                    if($where_str != '')
                    {
                        $pjBookingModel->where($where_str);
                    }
                }else{
                    $column = 't1.created';
                    $direction = 'ASC';
                    $where_str = pjUtil::getMadeWhere($_POST['made_period'], $this->option_arr['o_week_start']);
                    if($where_str != '')
                    {
                        $pjBookingModel->where($where_str);
                    }
                }
   
                $arr= $pjBookingModel
                    ->orderBy("$column $direction")
                    ->findAll()
                    ->getData();
                if($_POST['type'] == 'file')
                {
                    $this->setLayout('pjActionEmpty');
   
                    if($_POST['format'] == 'csv')
                    {
                        $csv = new pjCSV();
                        $csv
                            ->setHeader(true)
                            ->setName("Export-".time().".csv")
                            ->process($arr)
                            ->download();
                    }
                    if($_POST['format'] == 'xml')
                    {
                        $xml = new pjXML();
                        $xml
                            ->setEncoding('UTF-8')
                            ->setName("Export-".time().".xml")
                            ->process($arr)
                            ->download();
                    }
                    if($_POST['format'] == 'ical')
                    {
                        foreach($arr as $k => $v)
                        {
                            $end_ts = $v['start_ts'] + 60 * $v['service_length'];
                            $v['date_from'] = date('Y-m-d', $v['start_ts']) . ' ' . date('H:i:s', $v['start_ts']);
                            $v['date_to'] = date('Y-m-d', $end_ts) . ' ' . date('H:i:s', $end_ts);
                            $_arr = array();
                            if(!empty($v['c_name']))
                            {
                                $_arr[] = pjSanitize::html($v['c_name']);
                            }
                            if(!empty($v['service_name']))
                            {
                                $_arr[] = 'Service name: ' . pjSanitize::html($v['service_name']);
                            }
                            if(!empty($v['employee_name']))
                            {
                                $_arr[] = 'Employee name: ' . pjSanitize::html($v['employee_name']);
                            }
                            if(!empty($v['c_email']))
                            {
                                $_arr[] = 'Email: ' . pjSanitize::html($v['c_email']);
                            }
                            if(!empty($v['c_phone']))
                            {
                                $_arr[] = 'Phone: ' . pjSanitize::html($v['c_phone']);
                            }
                            if(!empty($v['booking_total']))
                            {
                                $_arr[] = 'Price: ' . pjSanitize::html($v['booking_total']);
                            }
                            if(!empty($v['c_notes']))
                            {
                                $_arr[] = 'Notes: ' . pjSanitize::html(preg_replace('/\n|\r|\r\n/', ' ', $v['c_notes']));
                            }
                            $_arr[] = 'Status: ' . pjSanitize::html($v['booking_status']);
                           
                            $v['desc'] = join("\; ", $_arr);
                            $v['location'] = '';
                            $v['summary'] = 'Booking';
                            $arr[$k] = $v;
                        }
                       
                        $ical = new pjICal();
                        $ical
                            ->setName("Export-".time().".ics")
                            ->setProdID('Appointment Scheduler')
                            ->setSummary('summary')
                            ->setCName('desc')
                            ->setLocation('location')
                            ->setTimezone(pjUtil::getTimezoneName($this->option_arr['o_timezone']))
                            ->process($arr)
                            ->download();
                    }
                    exit;
                }else{
                    $pjPasswordModel = pjPasswordModel::factory();
                    $password = md5($_POST['password'].PJ_SALT);
                    $arr = $pjPasswordModel
                        ->where("t1.password", $password)
                        ->limit(1)
                        ->findAll()
                        ->getData();
                    if (count($arr) != 1)
                    {
                        $pjPasswordModel->setAttributes(array('password' => $password))->insert();
                    }
                    $this->set('password', $password);
                }
            }
   
            $this->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/');
            $this->appendJs('pjAdminBookings.js');
        } else {
            $this->set('status', 2);
        }
    }
   
    public function pjActionExportFeed()
    {
        $this->setLayout('pjActionEmpty');
        $access = true;
        if(isset($_GET['p']))
        {
            $pjPasswordModel = pjPasswordModel::factory();
            $arr = $pjPasswordModel
                ->where('t1.password', $_GET['p'])
                ->limit(1)
                ->findAll()
                ->getData();
            if (count($arr) != 1)
            {
                $access = false;
            }
        }
        if($access == true)
        {
            $arr = $this->pjGetFeedData($_GET);
            if(!empty($arr))
            {
                if($_GET['format'] == 'xml')
                {
                    $xml = new pjXML();
                    echo $xml
                        ->setEncoding('UTF-8')
                        ->process($arr)
                        ->getData();
   
                }
                if($_GET['format'] == 'csv')
                {
                    $csv = new pjCSV();
                    echo $csv
                        ->setHeader(true)
                        ->process($arr)
                        ->getData();
   
                }
                if($_GET['format'] == 'ical')
                {
                    foreach($arr as $k => $v)
                    {
                        $end_ts = $v['start_ts'] + 60 * $v['service_length'];
                        $v['date_from'] = date('Y-m-d', $v['start_ts']) . ' ' . date('H:i:s', $v['start_ts']);
                        $v['date_to'] = date('Y-m-d', $end_ts) . ' ' . date('H:i:s', $end_ts);
                        $_arr = array();
                        if(!empty($v['c_name']))
                        {
                            $_arr[] = pjSanitize::html($v['c_name']);
                        }
                        if(!empty($v['service_name']))
                        {
                            $_arr[] = 'Service name: ' . pjSanitize::html($v['service_name']);
                        }
                        if(!empty($v['employee_name']))
                        {
                            $_arr[] = 'Employee name: ' . pjSanitize::html($v['employee_name']);
                        }
                        if(!empty($v['c_email']))
                        {
                            $_arr[] = 'Email: ' . pjSanitize::html($v['c_email']);
                        }
                        if(!empty($v['c_phone']))
                        {
                            $_arr[] = 'Phone: ' . pjSanitize::html($v['c_phone']);
                        }
                        if(!empty($v['booking_total']))
                        {
                            $_arr[] = 'Price: ' . pjSanitize::html($v['booking_total']);
                        }
                        if(!empty($v['c_notes']))
                        {
                            $_arr[] = 'Notes: ' . pjSanitize::html(preg_replace('/\n|\r|\r\n/', ' ', $v['c_notes']));
                        }
                        $_arr[] = 'Status: ' . pjSanitize::html($v['booking_status']);
   
                        $v['desc'] = join("\; ", $_arr);
                        $v['location'] = '';
                        $v['summary'] = 'Booking';
                        $arr[$k] = $v;
                    }
                       
                    $ical = new pjICal();
                    echo $ical
                        ->setProdID('Appointment Scheduler')
                        ->setSummary('summary')
                        ->setCName('desc')
                        ->setLocation('location')
                        ->setTimezone(pjUtil::getTimezoneName($this->option_arr['o_timezone']))
                        ->process($arr)
                        ->getData();
   
                }
            }
        }else{
            __('lblNoAccessToFeed');
        }
        exit;
    }
    public function pjGetFeedData($get)
    {
        $arr = array();
        $status = true;
        $type = '';
        $period = '';
        if(isset($get['period']))
        {
            if(!ctype_digit($get['period']))
            {
                $status = false;
            }else{
                $period = $get['period'];
            }
        }else{
            $status = false;
        }
        if(isset($get['type']))
        {
            if(!ctype_digit($get['type']))
            {
                $status = false;
            }else{
                $type = $get['type'];
            }
        }else{
            $status = false;
        }
        if($status == true && $type != '' && $period != '')
        {
            $pjBookingModel = pjBookingModel::factory()
                ->select('t1.*, t2.*, t3.total as service_length, t4.content as employee_name, t5.content as service_name')
                ->join('pjBookingService', 't2.booking_id=t1.id', 'left outer')
                ->join('pjService', 't2.service_id=t3.id', 'left outer')
                ->join('pjMultiLang', "t4.model='pjEmployee' AND t4.foreign_id=t2.employee_id AND t4.field='name' AND t4.locale='".$this->getLocaleId()."'", 'left outer')
                ->join('pjMultiLang', "t5.model='pjService' AND t5.foreign_id=t2.service_id AND t5.field='name' AND t5.locale='".$this->getLocaleId()."'", 'left outer');
           
            if($type == '1')
            {
                $column = 't2.date';
                $direction = 'ASC';
                   
                $where_str = pjUtil::getComingWhere($period, $this->option_arr['o_week_start']);
                if($where_str != '')
                {
                    $pjBookingModel->where($where_str);
                }
            }else{
                $column = 't1.created';
                $direction = 'DESC';
                $where_str = pjUtil::getMadeWhere($period, $this->option_arr['o_week_start']);
                if($where_str != '')
                {
                    $pjBookingModel->where($where_str);
                }
            }
            $arr= $pjBookingModel
                ->orderBy("$column $direction")
                ->findAll()
                ->getData();
        }
        return $arr;
    }
   
    public function pjActionGetBooking()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged() && $this->isAdmin())
        {
            $pjBookingModel = pjBookingModel::factory();
            $pjBookingServiceModel = pjBookingServiceModel::factory();
               
            if (isset($_GET['q']) && !empty($_GET['q']))
            {
                $q = $pjBookingModel->escapeString($_GET['q']);
                $q = str_replace(array('%', '_'), array('\%', '\_'), trim($q));
                $pjBookingModel->where(sprintf("t1.uuid LIKE '%1\$s' OR t1.c_email LIKE '%1\$s' OR t1.c_name LIKE '%1\$s'", "%$q%"));
            }

            if (isset($_GET['booking_status']) && !empty($_GET['booking_status']) && in_array((int) $_GET['booking_status'], array('confirmed', 'pending', 'cancelled')))
            {
                $pjBookingModel->where('t1.booking_status', $_GET['booking_status']);
            }
           
            if (isset($_GET['employee_id']) && (int) $_GET['employee_id'] > 0)
            {
                $pjBookingModel->where(sprintf("t1.id IN (SELECT `booking_id` FROM `%s` WHERE `employee_id` = '%u')", $pjBookingServiceModel->getTable(), (int) $_GET['employee_id']));
            }
           
            if (isset($_GET['service_id']) && (int) $_GET['service_id'] > 0)
            {
                $pjBookingModel->where(sprintf("t1.id IN (SELECT `booking_id` FROM `%s` WHERE `service_id` = '%u')", $pjBookingServiceModel->getTable(), (int) $_GET['service_id']));
            }
           
            if (isset($_GET['date_from']) && isset($_GET['date_to']) && !empty($_GET['date_from']) && !empty($_GET['date_to']))
            {
                $date_from = pjUtil::formatDate($_GET['date_from'], $this->option_arr['o_date_format']);
                $date_to = pjUtil::formatDate($_GET['date_to'], $this->option_arr['o_date_format']);
                $pjBookingModel->where(sprintf("t1.id IN (SELECT `booking_id` FROM `%s` WHERE `date` BETWEEN '%s' AND '%s')", $pjBookingServiceModel->getTable(), $date_from, $date_to));
            } else {
                if (isset($_GET['date_from']) && !empty($_GET['date_from']))
                {
                    $date_from = pjUtil::formatDate($_GET['date_from'], $this->option_arr['o_date_format']);
                    $pjBookingModel->where(sprintf("t1.id IN (SELECT `booking_id` FROM `%s` WHERE `date` >= '%s')", $pjBookingServiceModel->getTable(), $date_from));
                }
                if (isset($_GET['date_to']) && !empty($_GET['date_to']))
                {
                    $date_to = pjUtil::formatDate($_GET['date_to'], $this->option_arr['o_date_format']);
                    $pjBookingModel->where(sprintf("t1.id IN (SELECT `booking_id` FROM `%s` WHERE `date` <= '%s')", $pjBookingServiceModel->getTable(), $date_to));
                }
            }
           
            $column = 'id';
            $direction = 'DESC';
            if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC')))
            {
                $column = $_GET['column'];
                $direction = strtoupper($_GET['direction']);
            }

            $total = $pjBookingModel->findCount()->getData();
            $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10;
            $pages = ceil($total / $rowCount);
            $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1;
            $offset = ((int) $page - 1) * $rowCount;
            if ($page > $pages)
            {
                $page = $pages;
            }

            $data = $pjBookingModel
                ->select(sprintf("t1.*,
                    (SELECT GROUP_CONCAT(CONCAT_WS('~.~', bs.service_id, DATE_FORMAT(FROM_UNIXTIME(bs.start_ts), '%%Y-%%m-%%d %%H:%%i:%%s'), m.content) SEPARATOR '~:~')
                        FROM `%1\$s` AS `bs`
                        LEFT JOIN `%2\$s` AS `m` ON m.model='pjService' AND m.foreign_id=bs.service_id AND m.field='name' AND m.locale='%3\$u'
                        WHERE bs.booking_id = t1.id) AS `items`
                    ", $pjBookingServiceModel->getTable(), pjMultiLangModel::factory()->getTable(), $this->getLocaleId()))
                ->orderBy("$column $direction")->limit($rowCount, $offset)
                ->findAll()
                ->toArray('items', '~:~')
                ->getData();

            foreach ($data as $k => $v)
            {
                foreach ($data[$k]['items'] as $key => $val)
                {
                    $tmp = explode('~.~', $val);
                    if (isset($tmp[1]))
                    {
                        $tmp[1] = date($this->option_arr['o_datetime_format'], strtotime($tmp[1]));
                        $data[$k]['items'][$key] = join("~.~", $tmp);
                    }
                }
                $data[$k]['total_formated'] = pjUtil::formatCurrencySign(number_format($v['booking_total'], 2), $this->option_arr['o_currency']);
            }
               
            pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction'));
        }
        exit;
    }
   
    public function pjActionGetBookingService()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged() && $this->isEmployee())
        {
            $pjBookingServiceModel = pjBookingServiceModel::factory()
                ->join('pjBooking', 't2.id=t1.booking_id', 'inner')
                ->where('t1.employee_id', $this->getUserId());
               
            if (isset($_GET['q']) && !empty($_GET['q']))
            {
                $q = $pjBookingServiceModel->escapeString($_GET['q']);
                $q = str_replace(array('%', '_'), array('\%', '\_'), trim($q));
                $pjBookingServiceModel->where(sprintf("t2.uuid LIKE '%1\$s' OR t2.c_email LIKE '%1\$s' OR t2.c_name LIKE '%1\$s'", "%$q%"));
            }

            if (isset($_GET['booking_status']) && !empty($_GET['booking_status']) && in_array((int) $_GET['booking_status'], array('confirmed', 'pending', 'cancelled')))
            {
                $pjBookingServiceModel->where('t2.booking_status', $_GET['booking_status']);
            }
           
            if (isset($_GET['service_id']) && (int) $_GET['service_id'] > 0)
            {
                $pjBookingServiceModel->where('t1.service_id', $_GET['service_id']);
            }
           
            if (isset($_GET['date_from']) && isset($_GET['date_to']) && !empty($_GET['date_from']) && !empty($_GET['date_to']))
            {
                $date_from = pjUtil::formatDate($_GET['date_from'], $this->option_arr['o_date_format']);
                $date_to = pjUtil::formatDate($_GET['date_to'], $this->option_arr['o_date_format']);
                $pjBookingServiceModel->where(sprintf("(t1.date BETWEEN '%s' AND '%s')", $date_from, $date_to));
            } else {
                if (isset($_GET['date_from']) && !empty($_GET['date_from']))
                {
                    $date_from = pjUtil::formatDate($_GET['date_from'], $this->option_arr['o_date_format']);
                    $pjBookingServiceModel->where('t1.date >=', $date_from);
                }
                if (isset($_GET['date_to']) && !empty($_GET['date_to']))
                {
                    $date_to = pjUtil::formatDate($_GET['date_to'], $this->option_arr['o_date_format']);
                    $pjBookingServiceModel->where('t1.date <=', $date_to);
                }
            }
           
            $column = 't1.date';
            $direction = 'DESC';
            if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC')))
            {
                $column = $_GET['column'];
                $direction = strtoupper($_GET['direction']);
            }

            $total = $pjBookingServiceModel->findCount()->getData();
            $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10;
            $pages = ceil($total / $rowCount);
            $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1;
            $offset = ((int) $page - 1) * $rowCount;
            if ($page > $pages)
            {
                $page = $pages;
            }

            $data = $pjBookingServiceModel
                ->select("t1.*, t2.uuid, t2.booking_status, t2.c_name, t2.c_email, t2.c_phone, t3.content AS `service_name`")
                ->join('pjMultiLang', "t3.model='pjService' AND t3.foreign_id=t1.service_id AND t3.field='name' AND t3.locale='".$this->getLocaleId()."'", 'left outer')
                ->orderBy("$column $direction")->limit($rowCount, $offset)
                ->findAll()
                ->getData();

            foreach ($data as $k => $v)
            {
                $data[$k]['time'] = date($this->option_arr['o_datetime_format'], $v['start_ts']);
            }
               
            pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction'));
        }
        exit;
    }
   
    public function pjActionGetPrice()
    {
        $this->setAjax(true);
       
        if ($this->isXHR())
        {
            $price = $deposit = $tax = $total = 0;
           
            if (isset($_POST['id']) && (int) $_POST['id'] > 0)
            {
                $key = 't1.booking_id';
                $value = $_POST['id'];
            } elseif (isset($_POST['tmp_hash']) && !empty($_POST['tmp_hash'])) {
                $key = 't1.tmp_hash';
                $value = $_POST['tmp_hash'];
            }
           
            if (isset($key) && isset($value))
            {
                $bs_arr = pjBookingServiceModel::factory()->where($key, $value)->findAll()->getData();
                if(empty($bs_arr))
                {
                    pjAppController::jsonResponse(array('status' => 'ERR'));
                }
                foreach ($bs_arr as $service)
                {
                    $price += $service['price'];
                }
            }
           
            if ((float) $this->option_arr['o_tax'] > 0)
            {
                $tax = ($price * (float) $this->option_arr['o_tax']) / 100;
            }
           
            $total = $price + $tax;
           
            switch ($this->option_arr['o_deposit_type'])
            {
                case 'percent':
                    $deposit = ($total * (float) $this->option_arr['o_deposit']) / 100;
                    break;
                case 'amount':
                    $deposit = (float) $this->option_arr['o_deposit'];
                    break;
            }
           
            $data = compact('price', 'deposit', 'tax', 'total');
            $data = array_map('floatval', $data);
           
            pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => '', 'data' => $data));
        }
        exit;
    }
   
    public function pjActionGetService()
    {
        $this->setAjax(true);
   
        if ($this->isXHR())
        {
            if (isset($_GET['id']) && (int) $_GET['id'] > 0 && isset($_GET['date']) && !empty($_GET['date']))
            {
                $id = (int) $_GET['id'];
                $date = pjUtil::formatDate($_GET['date'], $this->option_arr['o_date_format']);
               
                $pjEmployeeServiceModel = pjEmployeeServiceModel::factory()
                    ->select("t1.*, t2.avatar, t2.calendar_id, t3.content AS `name`")
                    ->join('pjEmployee', 't2.id=t1.employee_id AND t2.is_active=1', 'inner')
                    ->join('pjMultiLang', "t3.model='pjEmployee' AND t3.foreign_id=t1.employee_id AND t3.field='name' AND t3.locale='".$this->getLocaleId()."'", 'left outer')
                    ->where('t1.service_id', $id)
                    ->orderBy('`name` ASC')
                    ->findAll();
               
                $employee_arr = $pjEmployeeServiceModel->getData();
                $employee_ids = $pjEmployeeServiceModel->getDataPair(null, 'employee_id');
                $bs_arr = array();
                if (!empty($employee_ids))
                {
                    $bs_arr = pjBookingServiceModel::factory()
                        ->join('pjBooking', "t1.booking_id=t2.id AND t2.booking_status='confirmed'", 'inner')
                        ->whereIn('t1.employee_id', $employee_ids)
                        ->where('t1.date', $date)
                        ->findAll()
                        ->getData();
                }
   
                foreach ($employee_arr as $k => $employee)
                {
                    $employee_arr[$k]['t_arr'] = pjAppController::getRawSlotsPerEmployee($employee['employee_id'], $date, $employee['calendar_id']);
                    $employee_arr[$k]['bs_arr'] = array();
                    foreach ($bs_arr as $item)
                    {
                        if ($item['employee_id'] != $employee['employee_id'])
                        {
                            continue;
                        }
                        $employee_arr[$k]['bs_arr'][] = $item;
                    }
                }
   
                $this
                    ->set('service_arr', pjServiceModel::factory()
                        ->select('t1.*, t2.content AS `name`')
                        ->join('pjMultiLang', "t2.model='pjService' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                        ->find($id)
                        ->getData()
                    )
                    ->set('employee_arr', $employee_arr);
            }
        }
    }
   
    public function pjActionIndex()
    {
        $this->checkLogin();
       
        if ($this->isAdmin())
        {
            $this->set('employee_arr', pjEmployeeModel::factory()
                ->select('t1.*, t2.content AS `name`')
                ->join('pjMultiLang', "t2.model='pjEmployee' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                ->orderBy('`name` ASC')
                ->findAll()
                ->getData()
            );
       
            $this->set('service_arr', pjServiceModel::factory()
                ->select('t1.*, t2.content AS `name`')
                ->join('pjMultiLang', "t2.model='pjService' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                ->orderBy('`name` ASC')
                ->findAll()
                ->getData()
            );
           
            $this->appendJs('jquery.datagrid.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/');
            $this->appendJs('pjAdminBookings.js');
            $this->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true);
        } else {
            $this->set('status', 2);
        }
    }
   
    public function pjActionList()
    {
        $this->checkLogin();
       
        if ($this->isEmployee())
        {
            $this->set('service_arr', pjServiceModel::factory()
                ->select('t1.*, t2.content AS `name`')
                ->join('pjMultiLang', "t2.model='pjService' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                ->orderBy('`name` ASC')
                ->where(sprintf("t1.id IN (SELECT `service_id` FROM `%s` WHERE `employee_id` = '%u')", pjEmployeeServiceModel::factory()->getTable(), $this->getUserId()))
                ->findAll()
                ->getData()
            );

            $this->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/');
            $this->appendJs('jquery.datagrid.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/');
            $this->appendJs('pjEmployeeBookings.js');
            $this->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true);
        } else {
            $this->set('status', 2);
        }
    }
   
    public function pjActionSaveBooking()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged())
        {
            $pjBookingModel = pjBookingModel::factory();
            if (!in_array($_POST['column'], $pjBookingModel->getI18n()))
            {
                $pjBookingModel->set('id', $_GET['id'])->modify(array($_POST['column'] => $_POST['value']));
            } else {
                pjMultiLangModel::factory()->updateMultiLang(array($this->getLocaleId() => array($_POST['column'] => $_POST['value'])), $_GET['id'], 'pjBooking');
            }
        }
        exit;
    }
   
    public function pjActionUpdate()
    {
        $this->checkLogin();
       
        if ($this->isAdmin())
        {
            $pjBookingModel = pjBookingModel::factory();
            if (isset($_REQUEST['id']) && (int) $_REQUEST['id'] > 0)
            {
                $pjBookingModel->where('t1.id', $_REQUEST['id']);
            } elseif (isset($_GET['uuid']) && !empty($_GET['uuid'])) {
                $pjBookingModel->where('t1.uuid', $_GET['uuid']);
            }
            $arr = $pjBookingModel
                ->limit(1)
                ->findAll()
                ->getData();
               
            if (empty($arr))
            {
                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminBookings&action=pjActionIndex&err=ABK08");
            }
            $arr = $arr[0];
           
            if (isset($_POST['booking_update']))
            {
                $data = array();
                if ($_POST['payment_method'] != "creditcard")
                {
                    $data['cc_type'] = ':NULL';
                    $data['cc_num'] = ':NULL';
                    $data['cc_code'] = ':NULL';
                    $data['cc_exp_year'] = ':NULL';
                    $data['cc_exp_month'] = ':NULL';
                }
                $arr = $pjBookingModel->find($_POST['id'])->getData();
                $pjInvoiceModel = pjInvoiceModel::factory();
                $_arr = $pjInvoiceModel->where('t1.order_id', $arr['uuid'])->limit(1)->findAll()->getData();
                $_arr = $_arr[0];
                $pjInvoiceModel->reset()->set('id', $_arr['id'])->modify(array('order_id'=>$_POST['uuid']));
                               
                pjBookingModel::factory()->set('id', $_POST['id'])->modify(array_merge($_POST, $data));
                pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjAdminBookings&action=pjActionIndex&err=ABK01");
               
            } else {
                $this->set('arr', $arr)
                    ->set('country_arr', pjCountryModel::factory()
                        ->select('t1.*, t2.content AS `name`')
                        ->join('pjMultiLang', "t2.model='pjCountry' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                        ->orderBy('`name` ASC')
                        ->findAll()->getData());
               
                $this->set('bi_arr', pjBookingServiceModel::factory()
                    ->select('t1.*, t2.content AS `title`')
                    ->join('pjMultiLang', sprintf("t2.model='pjService' AND t2.foreign_id=t1.service_id AND t2.field='name' AND t2.locale='%u'", $arr['locale_id']), 'left outer')
                    ->where('t1.booking_id', $arr['id'])
                    ->findAll()
                    ->getData()
                );
               
                $this
                    ->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/')
                    ->appendJs('jquery.datagrid.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/')
                    ->appendJs('pjAdminBookings.js')
                    ->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true)
                ;
            }
        } else {
            $this->set('status', 2);
        }
    }
       
    public function pjActionViewBookingService()
    {
        $this->setAjax(true);
       
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_GET['id']) && (int) $_GET['id'] > 0)
            {
                $arr = pjBookingServiceModel::factory()
                    ->select('t2.*, t1.*, t3.content AS `service_name`, t4.content AS `country_name`')
                    ->join('pjBooking', 't2.id=t1.booking_id', 'inner')
                    ->join('pjMultiLang', "t3.model='pjService' AND t3.foreign_id=t1.service_id AND t3.field='name' AND t3.locale='".$this->getLocaleId()."'", 'left outer')
                    ->join('pjMultiLang', "t4.model='pjCountry' AND t4.foreign_id=t2.c_country_id AND t4.field='name' AND t4.locale='".$this->getLocaleId()."'", 'left outer')
                    ->find($_GET['id'])
                    ->getData();
               
                $this->set('arr', $arr);
            }
        }
    }
   
    public function pjActionItemAdd()
    {
        $this->setAjax(true);
       
        if ($this->isXHR() && $this->isLoged())
        {
            $pjBookingServiceModel = pjBookingServiceModel::factory();
           
            if (isset($_POST['item_add']))
            {
                if (isset($_POST['service_id']) && (int) $_POST['service_id'] > 0)
                {
                    $date = pjUtil::formatDate($_POST['date'], $this->option_arr['o_date_format']);
               
                    $service_arr = pjServiceModel::factory()->find($_POST['service_id'])->getData();
                   
                    $bs_id = $pjBookingServiceModel->reset()->setAttributes(array(
                        'tmp_hash' => @$_POST['tmp_hash'],
                        'booking_id' => @$_POST['booking_id'],
                        'service_id' => $_POST['service_id'],
                        'employee_id' => $_POST['employee_id'],
                        'date' => $date,
                        'start' => date("H:i:s", $_POST['start_ts']),
                        'start_ts' => $_POST['start_ts'],
                        'total' => @$service_arr['total'],
                        'price' => @$service_arr['price']
                    ))->insert()->getInsertId();
                   
                    if ($bs_id !== FALSE && (int) $bs_id > 0)
                    {
                        pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => 'Service has been added.'));
                    }
                    pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Service has not been added.'));
                }
                pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Service couldn\'t be empty.'));
            }
           
            $service_arr = pjServiceModel::factory()
                ->select('t1.*, t2.content AS `name`')
                ->join('pjMultiLang', "t2.model='pjService' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'", 'left outer')
                ->where('t1.is_active', 1)
                ->findAll()->getData();
           
            $this->set('service_arr', $service_arr);
        }
    }
   
    public function pjActionItemDelete()
    {
        $this->setAjax(true);
       
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_POST['id']) && (int) $_POST['id'] > 0)
            {
                $pjBookingServiceModel = pjBookingServiceModel::factory();
                $arr = $pjBookingServiceModel->find($_POST['id'])->getData();
                if (empty($arr))
                {
                    pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 103, 'text' => 'Item not found.'));
                }
                if (1 == $pjBookingServiceModel->set('id', $_POST['id'])->erase()->getAffectedRows())
                {
                    pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => 'Item has been deleted.'));
                }
                pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 102, 'text' => 'Item has not been deleted.'));
            }
            pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 101, 'text' => 'Missing parameters.'));
        }
        pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Access denied.'));
        exit;
    }
   
    public function pjActionItemGet()
    {
        $this->setAjax(true);
       
        if ($this->isXHR() && $this->isLoged())
        {
            $pjBookingServiceModel = pjBookingServiceModel::factory()
                ->select("t1.*, t2.content AS `service`, t3.content AS `employee`")
                ->join('pjMultiLang', "t2.model='pjService' AND t2.foreign_id=t1.service_id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'")
                ->join('pjMultiLang', "t3.model='pjEmployee' AND t3.foreign_id=t1.employee_id AND t3.field='name' AND t3.locale='".$this->getLocaleId()."'");
           
            if (isset($_GET['booking_id']) && (int) $_GET['booking_id'] > 0)
            {
                $pjBookingServiceModel
                    ->join('pjBooking', 't4.id=t1.booking_id', 'inner')
                    ->where('t1.booking_id', $_GET['booking_id']);
            } elseif (isset($_GET['tmp_hash']) && !empty($_GET['tmp_hash'])) {
                $pjBookingServiceModel->where('t1.tmp_hash', $_GET['tmp_hash']);
            } else {
                $pjBookingServiceModel->where('t1.id', -999);
            }
            $bi_arr = $pjBookingServiceModel->findAll()->getData();
           
            $this->set('bi_arr', $bi_arr);
        }
    }

    public function pjActionItemEmail()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_POST['send_email']) && isset($_POST['to']) && !empty($_POST['to']) && !empty($_POST['from']) &&
                !empty($_POST['subject']) && !empty($_POST['message']) && !empty($_POST['id']))
            {
                $Email = new pjEmail();
                $Email->setContentType('text/html');
                if ($this->option_arr['o_send_email'] == 'smtp')
                {
                    $Email
                        ->setTransport('smtp')
                        ->setSmtpHost($this->option_arr['o_smtp_host'])
                        ->setSmtpPort($this->option_arr['o_smtp_port'])
                        ->setSmtpUser($this->option_arr['o_smtp_user'])
                        ->setSmtpPass($this->option_arr['o_smtp_pass']);
                }
               
                $r = false;
                if (isset($_POST['message']) && !empty($_POST['message']))
                {
                    $message = pjUtil::textToHtml($_POST['message']);
                    foreach ($_POST['to'] as $recipient)
                    {
                        $r = $Email
                            ->setTo($recipient)
                            ->setFrom($_POST['from'])
                            ->setSubject($_POST['subject'])
                            ->send($message);
                    }
                }
                   
                if ($r)
                {
                    pjBookingServiceModel::factory()->set('id', $_POST['id'])->modify(array('reminder_email' => 1));
                    pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => 'Email has been sent.'));
                }
                pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Email failed to send.'));
            }
           
            if (isset($_GET['id']) && (int) $_GET['id'] > 0)
            {
                $booking_arr = pjBookingServiceModel::factory()
                    ->select('t2.*, t1.*, t3.length, t3.before, t4.content AS `service_name`,
                        t6.email AS `admin_email`, t7.content AS `country_name`, t8.email AS `employee_email`')
                    ->join('pjBooking', 't2.id=t1.booking_id', 'inner')
                    ->join('pjService', 't3.id=t1.service_id', 'inner')
                    ->join('pjMultiLang', "t4.model='pjService' AND t4.foreign_id=t1.service_id AND t4.field='name' AND t4.locale=t2.locale_id", 'left outer')
                    ->join('pjCalendar', 't5.id=t2.calendar_id', 'left outer')
                    ->join('pjUser', 't6.id=t5.user_id', 'left outer')
                    ->join('pjMultiLang', "t7.model='pjCountry' AND t7.foreign_id=t2.c_country_id AND t7.locale=t2.locale_id AND t7.field='name'", 'left outer')
                    ->join('pjEmployee', 't8.id=t1.employee_id', 'left outer')
                    ->find($_GET['id'])
                    ->getData();
               
                $tokens = pjAppController::getTokens($booking_arr, $this->option_arr);
               
                $subject_client = str_replace($tokens['search'], $tokens['replace'], $this->option_arr['o_reminder_subject']);
                $message_client = str_replace($tokens['search'], $tokens['replace'], $this->option_arr['o_reminder_body']);
               
                $this->set('arr', array(
                    'id' => $_GET['id'],
                    //'to' => $booking_arr['c_email'],
                    'client_email' => $booking_arr['c_email'],
                    'employee_email' => $booking_arr['employee_email'],
                    'from' => !empty($booking_arr['admin_email']) ? $booking_arr['admin_email'] : $booking_arr['c_email'],
                    'message' => $message_client,
                    'subject' => $subject_client
                ));
            } else {
                exit;
            }
        }
    }
   
    public function pjActionItemSms()
    {
        $this->setAjax(true);
   
        if ($this->isXHR() && $this->isLoged())
        {
            if (isset($_POST['send_sms']) && isset($_POST['to']) && !empty($_POST['to']) && !empty($_POST['message']) && !empty($_POST['id']))
            {
                $params = array(
                    'text' => $_POST['message'],
                    'type' => 'unicode',
                    'key' => md5($this->option_arr['private_key'] . PJ_SALT)
                );
               
                foreach ($_POST['to'] as $recipient)
                {
                    $params['number'] = $recipient;
                    $result = $this->requestAction(array('controller' => 'pjSms', 'action' => 'pjActionSend', 'params' => $params), array('return'));
                }

                if ((int) $result === 1)
                {
                    pjBookingServiceModel::factory()->set('id', $_POST['id'])->modify(array('reminder_sms' => 1));
                    pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => 'SMS has been sent.'));
                }
                pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'SMS failed to send.'));
            }
           
            if (isset($_GET['id']) && (int) $_GET['id'] > 0)
            {
                $booking_arr = pjBookingServiceModel::factory()
                    ->select('t2.*, t1.*, t3.before, t3.length, t4.content AS `service_name`,
                        t6.email AS `admin_email`, t7.content AS `country_name`, t8.phone AS `employee_phone`')
                    ->join('pjBooking', 't2.id=t1.booking_id', 'inner')
                    ->join('pjService', 't3.id=t1.service_id', 'inner')
                    ->join('pjMultiLang', "t4.model='pjService' AND t4.foreign_id=t1.service_id AND t4.field='name' AND t4.locale=t2.locale_id", 'left outer')
                    ->join('pjCalendar', 't5.id=t2.calendar_id', 'left outer')
                    ->join('pjUser', 't6.id=t5.user_id', 'left outer')
                    ->join('pjMultiLang', "t7.model='pjCountry' AND t7.foreign_id=t2.c_country_id AND t7.locale=t2.locale_id AND t7.field='name'", 'left outer')
                    ->join('pjEmployee', 't8.id=t1.employee_id', 'left outer')
                    ->find($_GET['id'])
                    ->getData();
               
                $tokens = pjAppController::getTokens($booking_arr, $this->option_arr);
               
                $message_client = str_replace($tokens['search'], $tokens['replace'], $this->option_arr['o_reminder_sms_message']);
               
                $this->set('arr', array(
                    'id' => $_GET['id'],
                    //'to' => $booking_arr['c_phone'],
                    'client_phone' => $booking_arr['c_phone'],
                    'employee_phone' => $booking_arr['employee_phone'],
                    'message' => $message_client
                ));
            } else {
                exit;
            }
        }
    }
}
?>
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester