<?php
 require_once(dirname(__FILE__).'/../../base-lib.inc'); class RADChangeCredit extends SSXApp { var $own_name = 'rad_change_credit'; public function __construct() { parent::__construct(array('appname'=>'suite')); if ( isset($argv[0])) { $this->own_name = $argv[0]; if ( get_num_of_running_prog( $this->own_name) > 1) { $this->log( CMMN_INFO, $this->own_name, __FILE__, __LINE__, '', "Another copy of program - is running. Exiting"); return false; } } return $this; } public function change($gid, $default_credit, $coeff_for_credit) { if ( !$this->db->Execute("UPDATE sk_users SET credit=".$default_credit." WHERE gid=".$gid)) { $this->log(CMMN_ERROR, $this->own_name, __FILE__, __LINE__, $this->db->errorMsg(), "Can not execute query"); return false; } if ( !$this->db->Execute("
	UPDATE sk_users SET credit=".$coeff_for_credit."*monthly_money(uid) WHERE gid=".$gid." AND ".$default_credit."<".$coeff_for_credit."*monthly_money(uid)
	")) { $this->log(CMMN_ERROR, $this->own_name, __FILE__, __LINE__, $this->db->errorMsg(), "Can not execute query"); return false; } return true; } } ?>