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); }
/** * 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); }
/** * Check if module is enabled * @param type $module_id * @return type */ public static function isModuleEnabled($module_id) { return ModulesEnabled::model()->isModuleEnabled($module_id); }