Exemplo n.º 1
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $setID = intval($_POST["id"]);
            $set = ServiceLevelSettings::model()->findByPk($setID);

            if ($set) {
                $set->Tier_Name = $_POST["Tier_Name"] ? $_POST["Tier_Name"] : null;
                $set->Users_Count = $_POST["Users_Count"] ? $_POST["Users_Count"] : null;
                $set->Projects_Count = $_POST["Projects_Count"] ? $_POST["Projects_Count"] : null;
                $set->Storage_Count = $_POST["Storage_Count"] ? $_POST["Storage_Count"] : null;
                $set->Base_Fee = $_POST["Base_Fee"] ? $_POST["Base_Fee"] : null;
                $set->Additional_User_Fee = $_POST["Additional_User_Fee"] ? $_POST["Additional_User_Fee"] : null;
                $set->Additional_Project_Fee = $_POST["Additional_Project_Fee"] ? $_POST["Additional_Project_Fee"] : null;
                $set->Additional_Storage_Fee = $_POST["Additional_Storage_Fee"] ? $_POST["Additional_Storage_Fee"] : null;
                $set->Trial_Period = $_POST["Trial_Period"] ? $_POST["Trial_Period"] : null;
                $set->Description = $_POST["Description"] ? $_POST["Description"] : null;
                if ($set->validate()) {
                    $set->save();
                    echo "settings\n";
                }
            }

            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            die;
        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "Service Level ID"; // caption of column
        $col["name"] = "Service_Level_ID";
        $col["dbname"] = "Service_Level_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Tier Name"; // caption of column
        $col["name"] = "Tier_Name";
        $col["dbname"] = "Tier_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Users Count"; // caption of column
        $col["name"] = "Users_Count";
        $col["dbname"] = "Users_Count"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Projects Count"; // caption of column
        $col["name"] = "Projects_Count";
        $col["dbname"] = "Projects_Count"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Storage Count"; // caption of column
        $col["name"] = "Storage_Count";
        $col["dbname"] = "Storage_Count"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Base Fee"; // caption of column
        $col["name"] = "Base_Fee";
        $col["dbname"] = "Base_Fee"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional User Fee"; // caption of column
        $col["name"] = "Additional_User_Fee";
        $col["dbname"] = "Additional_User_Fee"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional Project Fee"; // caption of column
        $col["name"] = "Additional_Project_Fee";
        $col["dbname"] = "Additional_Project_Fee"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional Storage Fee"; // caption of column
        $col["name"] = "Additional_Storage_Fee";
        $col["dbname"] = "Additional_Storage_Fee"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Trial_Period"; // caption of column
        $col["name"] = "Trial_Period";
        $col["dbname"] = "Trial_Period"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Description"; // caption of column
        $col["name"] = "Description";
        $col["dbname"] = "Description"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = false;
        $col["edittype"] = "textarea";
        $col["editoptions"] = array("rows"=>15, "cols"=>80);
        $cols[] = $col;


        $g = new jqgrid();

        $grid["caption"] = "Service Level Settings";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Service_Level_ID';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'600',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>true, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>false, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT service_level_settings.*
                              FROM service_level_settings";

        // set database table for CRUD operations
        $g->table = "service_level_settings";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Service_Level_ID', // group starts from this column
                        "numberOfColumns"=>11, // group span to next 2 columns
                        "titleText"=>'Service Level Settings Information' // caption of group header
                    ),
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("service_level_settings");

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Exemplo n.º 2
0
        <label for="service_names_dropdown"><span class="red">*</span> Tiers Selected</label><br/><br/>

        <?php
        $items =  ServiceLevelSettings::getServiceLevelsOptionsList();
        $this->renderPartial('application.views.widgets.dropdown_search_style_txtfield', array(
            'items'=> $items,
            'level_ids'=>$level_ids,
            'summary_sl_settings'=>$summary_sl_settings
        ));
        ?>

    </div>

    <div class="row">
        <label for="active_to_dropdown"><span class="red">*</span>End Date (mm/dd/YYYY)</label>
        <?php echo $form->dropDownList($client_service_settings, 'Active_To', ServiceLevelSettings::getNextActiveToList( $client_service_settings->Active_To),
            array(
                'id'=>'active_to_dropdown',
                'class'=>'txtfield',
                'data-initial-value'=>date('m/d/Y',strtotime($client_service_settings->Active_To))
            ));?>
    </div>
    <div class="row">
        <label for="service_add_users_input"><span class="red">*</span> Users count (used <?=$summary_sl_settings['Used_Users']?> of <?=$client_service_settings->Additional_Users+$summary_sl_settings['Users_Count']?> allowed )
            $<?=$serviceLevels[0]->Additional_User_Fee;?>
        </label>
        <?php
        $total_users = $client_service_settings->Additional_Users+$summary_sl_settings['Users_Count'];
        $total_users = ($total_users > $summary_sl_settings['Used_Users']) ?  $total_users : $summary_sl_settings['Used_Users']; //value should not be less than minimum
        echo $form->textField($client_service_settings,'Additional_Users', array(
            'id'=>'service_add_users_input',
Exemplo n.º 3
0
    /**
     * Returns array of summarized settings for current client
     * @return array Tier_Name,Users_Count, Projects_Count, Storage_Count, Base_Fee, Additional_Users,Additional_Projects,Additional_Storage,Additional_Fee
     */
    public static function getSummarySettings($client_id) {
        $result = array();
        $i= 0;
        $limiter ='';
        $client_id = $client_id ? $client_id :Yii::app()->user->clientID;

        $css = ClientServiceSettings::model()->findByPk($client_id);
        $result['Tiers_Str'] = $css->Service_Level_ID;
        $tiers_array = explode(',',$result['Tiers_Str']);
        foreach ($tiers_array as $id) {
            $settings = ServiceLevelSettings::model()->findByPk($id);

            if ($i != 0) {$limiter = ', ';}
            if ($settings->Service_Level_ID == 1) {
                $w9_exist =true;
                $w9_price = $settings->Base_Fee;
                $result['levels_checksum']+=1;
            }
            if ($settings->Service_Level_ID == 2) {
                $result['levels_checksum']+=5;
            }
            if ($settings->Service_Level_ID == 3) {
                $result['levels_checksum']+=10;
            }if ($settings->Service_Level_ID == 4) {
                $result['levels_checksum']+=20;
            }

            $result['Tier_Name'] .= $limiter.$settings->Tier_Name;
            $i++;
         }

        $add_users_price = $settings->Additional_User_Fee;
        $add_projects_price = $settings->Additional_Project_Fee;
        $add_storage_price = $settings->Additional_Storage_Fee;

        $result['Base_Fee'] =  ClientServiceSettings::CalculateBaseFee($tiers_array);
        $result['Users_Count'] = $settings->Users_Count;
        $result['Projects_Count'] = $settings->Projects_Count;
        $result['Storage_Count'] = $settings->Storage_Count;

            $result['Additional_Users'] =$css->Additional_Users;
            $result['Additional_Projects'] =$css->Additional_Projects;
            $result['Additional_Storage'] =$css->Additional_Storage;
            $result['Storage_Index'] = ServiceLevelSettings::getStorageIndexByValue($css->Additional_Storage);
            $result['Additional_Fee'] = $add_users_price * $css->Additional_Users + $add_projects_price*($css->Additional_Projects) + $add_storage_price* ($result['Storage_Index']);

            //$result['Additional_Storage'] =$settings->	Additional_Storage;

        $users = UsersClientList::model()->findAllByAttributes(array(
            'Client_ID'=>$client_id
        ));
        $result['Used_Users'] =count($users);

        $result['Used_Projects'] = Projects::clientProjectUsage();
        $result['Used_Storage'] = ceil(Images::getUsedStorage($client_id));


        return $result;
    }
Exemplo n.º 4
0
    public function generateTabsForAutoLoad (){

        if ( $_SESSION['tabs_to_auto_load']['client_service_level_settings']) {

                $client_id_to_rewiev = intval($_SESSION['tabs_to_auto_load']['client_service_level_settings']['client_id']);

                $client = Clients::model()->with('service_settings', 'service_payments','company')->findByPk($client_id_to_rewiev);
                if ($client) {
                    $serviceLevels = ServiceLevelSettings::getServiceLevelsOptionsList();
                    $settings = $client->service_settings;
                    $items =  ServiceLevelSettings::getServiceLevelsOptionsList();
                    $summary_sl_settings = ServiceLevelSettings::getSummarySettings($client_id_to_rewiev);
                    $dcss = DelayedClientServiceSettings::model()->findByPk($client_id_to_rewiev);
                    $pending_client_service_settings = PendingClientServiceSettings::model()->findByAttributes(array(
                        'Client_ID'=> $client->Client_ID,
                        'Approved'=>1
                    ));

                    $view_data =  $this->renderPartial('client_service_level_settings' , array(
                        'client' => $client,
                        'settings' => $settings,
                        'payments' => $client->service_payments,
                        'serviceLevels' => $serviceLevels,
                        'items'=>$items,
                        'summary_sl_settings'=>$summary_sl_settings,
                        'pending_client_service_settings'=>$pending_client_service_settings,
                        'dcss'=>$dcss
                    ),true);

                    $return_array['client_service_level_settings']['auto_loaded_data'] = $view_data;
                    $return_array['client_service_level_settings']['client'] = $client;
                }
        }

        if ( $_SESSION['tabs_to_auto_load']['client_users_list_appr_value']) {
            $client_id_to_rewiev = intval($_SESSION['tabs_to_auto_load']['client_users_list_appr_value']['client_id']);
            $approvers_array = UsersClientList::getApproversArray($client_id_to_rewiev);

            $view_data =  $this->renderPartial('client_users_list_appr_value' , array(
                         'approvers_array'=>$approvers_array,
            ),true);

            $return_array['client_users_list_appr_value']['auto_loaded_data'] = $view_data;
            $return_array['client_users_list_appr_value']['client'] = Clients::model()->with('company', 'users')->findByPk($client_id_to_rewiev);;
        }

        return $return_array;
    }
Exemplo n.º 5
0
    public static function CalculateAddFee($users,$projects,$storage){


        $storage_index = ServiceLevelSettings::getStorageIndexByValue($storage);

        return $users*9.95+($projects-1)*4.95+($storage_index)*7.95;
    }
Exemplo n.º 6
0
    /**
     * Generate invoice
     * @param $clientID
     * @param $amount
     */
    public static function generateInvoice($clientID, $userID, $amount)
    {

       $client = Clients::model()->with('company.adreses')->findByPk($clientID);

       $user = Users::model()->with('person')->findByPk($userID);


        $settingsToPay= PendingClientServiceSettings::model()->findByAttributes(array(
            'Client_ID'=>$clientID,
            'Approved'=>1
            )
        );


        if($settingsToPay) {
            //$str = ServiceLevelSettings::getSummaryName($settingsToPay->Service_Level_ID);

            $sum_settings = ServiceLevelSettings::getSummarySettings($clientID);
            $tierName=$sum_settings['Tier_Name'];

            $data['service']['total_users'] = $settingsToPay->Additional_Users ;
            $data['service']['total_projects'] = $settingsToPay->Additional_Projects ;
            $data['service']['total_storage'] = $settingsToPay->Additional_Storage ;

            $data['service']['added_users'] = $settingsToPay->Additional_Users - $sum_settings['Users_Count'];
            $data['service']['added_projects'] = $settingsToPay->Additional_Projects ;
            $data['service']['added_storage'] = $settingsToPay->Additional_Storage ;

            $active_to = $settingsToPay->Pending_Active_To;
        }
        else {
            $settingsToPay= ClientServiceSettings::model()->findByPk($clientID);
            $sum_settings = ServiceLevelSettings::getSummarySettings($clientID);
            $tierName=$sum_settings['Tier_Name'];

            $data['service']['total_users'] = $settingsToPay->Additional_Users + $sum_settings['Users_Count'];
            $data['service']['total_projects'] = $settingsToPay->Additional_Projects + $sum_settings['Projects_Count'];
            $data['service']['total_storage'] = $settingsToPay->Additional_Storage + $sum_settings['Storage_Count'];

            $data['service']['added_users'] = $settingsToPay->Additional_Users;
            $data['service']['added_projects'] = $settingsToPay->Additional_Projects;
            $data['service']['added_storage'] = $settingsToPay->Additional_Storage;

            $active_to = $settingsToPay->Active_To;

        }

        $summary_sl_settings = ServiceLevelSettings::getSummarySettings($clientID);

        $data['company_to']['company_name']=$client->company->Company_Name;
        $data['company_to']['street']=$client->company->adreses[0]->Address1;
        $data['company_to']['city']=$client->company->adreses[0]->City."  ".$client->company->adreses[0]->ZIP;;
        $data['company_to']['country']=$client->company->adreses[0]->Country;
        $data['company_to']['email']=$user->person->Email;
        $data['company_to']['phone']=$user->person->Mobile_Phone;

        $data['invoice']['number']=Aps::generateInvoiceNumber($clientID);
        $data['invoice']['date']=date("M d, Y",time());
        $data['invoice']['due_date']=date("M d, Y",time());
        $data['invoice']['due_date']=date("M d, Y",time());
        $data['invoice']['amount_due']=$amount;

        $data['service']['service_name']=$tierName;


        /*$data['service']['Users']=$summary_sl_settings['Additional_Users']+$summary_sl_settings['Users_Count'];
        $data['service']['Projects']=$summary_sl_settings['Additional_Projects']+$summary_sl_settings['Projects_Count'];
        $data['service']['Storage']=$summary_sl_settings['Additional_Storage']+$summary_sl_settings['Storage_Count'];*/
        $data['service']['active_to'] = $active_to;




        // get content for pdf
        $content = Yii::app()->controller->renderPartial('application.views.myaccount.invoice_template', array(
            'data'=>$data,
        ), true);

        $fileName = date("Y_m_d_H_i_s") . '.pdf';
        Yii::import('ext.html2pdf.HTML2PDF');
        $html2pdf = new HTML2PDF('P', 'A4', 'en');
        $html2pdf->writeHTML($content);
        $html2pdf->Output($fileName, 'I');
        die;
    }