-- web pass change
-- WEB login 
nic083
$user_hash = strtolower(md5($user_password));  -> user_hash 358d11798c6e11d0ab92b5169cfd74d0
if($this->authenticate_user($user_hash)){  ->  checks users table with hash as below:
	$query = "SELECT * FROM $this->table_name WHERE user_name='$this->user_name' AND user_hash='$password' AND (portal_only IS NULL OR portal_only !='1') AND (is_group IS NULL OR is_group !='1') ";

-- password henko -> 
- first ajax function	
function encrypt_password(){
	$password = $_REQUEST['password'];
	echo md5($password);
}

- then Users Save

$encrypted_password = $this->encrypt_password($user_password);			-> 03QaV02Qmp8QU
$encrypted_new_password = $this->encrypt_password($new_password);		-> 03ciwGXXwpN8s

$query = "SELECT user_name FROM $this->table_name WHERE user_password='$encrypted_password' AND id='$this->id'";


-- henkin data shusei

SELECT fee_subcategory, basic_fee, smsevent.school_id, sms_fee.school_id, sms_transaction.school_id, sms_transaction.nyukin_school_id
FROM sms_fee, sms_fee_sub1, sms_transaction, smsevent
WHERE sms_fee.id=sms_fee_sub1.id_sub1 AND sms_transaction.fee_id=sms_fee.id AND sms_fee.event_id=smsevent.id AND smsevent.deleted=0 AND sms_fee.deleted=0 AND sms_transaction.deleted=0 
	AND fee_subcategory IN ('受講料', '教材費', '設備費') AND fee_shokubun=1

-- honban & test site	
UPDATE sms_fee, sms_fee_sub1, sms_transaction, smsevent
SET sms_fee.school_id=smsevent.school_id, sms_transaction.school_id=smsevent.school_id
WHERE sms_fee.id=sms_fee_sub1.id_sub1 AND sms_transaction.fee_id=sms_fee.id AND sms_fee.event_id=smsevent.id AND smsevent.deleted=0 AND sms_fee.deleted=0 AND sms_transaction.deleted=0 
	AND fee_subcategory IN ('受講料', '教材費', '設備費') AND fee_shokubun=1

-- test site only
SELECT fee_subcategory, basic_fee, smsevent.school_id, sms_fee.school_id, sms_transaction.school_id, sms_transaction.nyukin_school_id, t_date
FROM sms_fee, sms_fee_sub1, sms_transaction, smsevent
WHERE sms_fee.id=sms_fee_sub1.id_sub1 AND sms_transaction.fee_id=sms_fee.id AND sms_fee.event_id=smsevent.id AND smsevent.deleted=0 AND sms_fee.deleted=0 AND sms_transaction.deleted=0 
	AND fee_subcategory IN ('手数料')  AND t_date IS NULL

UPDATE sms_fee, sms_fee_sub1, sms_transaction, smsevent
SET sms_fee.school_id=smsevent.school_id, sms_transaction.school_id=smsevent.school_id
WHERE sms_fee.id=sms_fee_sub1.id_sub1 AND sms_transaction.fee_id=sms_fee.id AND sms_fee.event_id=smsevent.id AND smsevent.deleted=0 AND sms_fee.deleted=0 AND sms_transaction.deleted=0 
	AND fee_subcategory IN ('手数料')  AND t_date IS NULL


-- honban DB sms_event_instance & sms_recurrence shusei

SELECT smsevent_instances . *
FROM sms_event_instance_backup, smsevent_instances
WHERE sms_event_instance_backup.date_modified LIKE '2015-01-19%'
AND smsevent_instances.event_id = sms_event_instance_backup.parent_id
AND category = 'student'


SELECT sms_event_instance.* FROM sms_event_instance, smsevent_instances
WHERE smsevent_instances.instance_id = sms_event_instance.id

SELECT smsevent_instances.* FROM smsevent_instances LEFT JOIN sms_event_instance ON smsevent_instances.instance_id = sms_event_instance.id WHERE sms_event_instance.id IS NULL
		--	intance_id										event_id
		--	de65f6ff-5bc4-1993-e03d-54ab3acadb2a 	6c1bf6cb-fc8b-e04f-7ac9-54603674d898
		-- file ACC_smsevent_instances with no instance.xls
		
SELECT * FROM `event_contacts` WHERE `date_modified` > '2015-01-19 17:33' AND deleted=0  -->  43 records
-- courses be9cf3dd-7a98-8d1f-f437-54bccf90bf82  &  cb23198e-8ae6-2f5c-067a-54bcc5a9113d 	have NULL values for start & end dates, but they also have no schedule  ->  IT IS OK




