/** * Add billing * @param type $org_model * @param type $sms_model * @param type $recipients_count * @return boolean */ public static function addBilling($org_model, $sms_model, $recipients_count) { if (!ModulesEnabled::model()->isModuleEnabled(ModulesEnabled::MOD_BILLING)) { return FALSE; } $message_length = strlen($sms_model->message); $no_of_sms = ceil($message_length / self::MAX_SMS_LENGTH); $price_per_sms = !empty($org_model->price_per_sms) ? $org_model->price_per_sms : OrgSmsBilling::getDefaultPricePerSms(); $total_cost = $price_per_sms * $no_of_sms * $recipients_count; $model = new OrgSmsBilling(); $model->org_id = $sms_model->org_id; $model->msg_batch_id = $sms_model->batch_id; $model->no_of_recipients = $recipients_count; $model->no_of_sms = $no_of_sms; $model->message_length = $message_length; $model->total_amount = $total_cost; $model->paid_amount = $org_model->acc_balance >= $total_cost ? $total_cost : $org_model->acc_balance; if ($model->paid_amount < 0) { $model->paid_amount = 0; } else { $model->payment_date = new CDbExpression('NOW()'); } $model->payment_status = $model->paid_amount < $model->total_amount ? OrgSmsBilling::PAYMENT_STATUS_PENDING : OrgSmsBilling::PAYMENT_STATUS_PAID; $model->pending_amount = $model->total_amount - $model->paid_amount; $model->save(); $org_model->acc_balance -= $total_cost; $org_model->save(FALSE); }
public function actionUpdateStatus($id, $status) { $this->hasPrivilege(Acl::ACTION_UPDATE); if (!array_key_exists($status, ModulesEnabled::getStatuses())) { throw new CHttpException(403, Lang::t('403_error')); } $model = ModulesEnabled::model()->loadModel($id); $model->status = $status; $model->save(FALSE); }
<?php echo $form->labelEx($model, 'description', array('class' => 'col-lg-2 control-label')); ?> <div class="col-lg-4"> <?php echo $form->textArea($model, 'description', array('class' => 'form-control', 'rows' => 3, 'maxlength' => 255)); ?> </div> </div> <div class="form-group"> <?php echo $form->labelEx($model, 'status', array('class' => 'col-lg-2 control-label')); ?> <div class="col-lg-4"> <?php echo $form->dropDownList($model, 'status', ModulesEnabled::getStatuses(), array('class' => 'form-control')); ?> </div> </div> <div class="clearfix form-actions"> <div class="col-lg-offset-2 col-lg-9"> <button class="btn btn-primary" type="submit"><i class="icon-ok bigger-110"></i> <?php echo Lang::t($model->isNewRecord ? 'Create' : 'Save changes'); ?> </button> <a class="btn" href="<?php echo $this->createUrl('index'); ?> "><i class="icon-remove bigger-110"></i><?php echo Lang::t('Cancel');
/** * Check if module is enabled * @param type $module_id * @return type */ public static function isModuleEnabled($module_id) { return ModulesEnabled::model()->isModuleEnabled($module_id); }