Ejemplo n.º 1
0
}
$DataCSVFile = "wecaredata3.csv";
$dataDir = "/home/ubuntu/data/doc3/";
if (!validateDirStr($dataDir)) {
    die("\n invalid File Structure\n");
}
$config['host'] = "localhost";
$config['user'] = "******";
$config['password'] = "******";
$config['database'] = "bluenet_v3";
$db_handle = mysqli_connect($config['host'], $config['user'], $config['password'], $config['database']);
if (($handle = fopen($DataCSVFile, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $lName = $data[8];
        $lMobile = $data[9];
        $lAddress = $data[4];
        $localId = $data[0];
        $wName = $data[1];
        $wMobile = $data[2];
        $wAddress = $data[7];
        $service = $data[6];
        $emergency_no = $data[3];
        $native_add = $data[5];
        $refId = createCustomer($db_handle, $lName, $lMobile, $lAddress);
        $outArray = UploadDocs($dataDir, $localId);
        $wId = createCustomerWorker($db_handle, $wName, $wMobile, $wAddress, $outArray['photo'], $refId, $localId, $service, $outArray['pv'], $outArray['adhar_card'], $outArray['voter_card'], $outArray['driving_license'], $outArray['pan_card'], $emergency_no, $native_add);
        echo $wId . ",";
    }
    fclose($handle);
}
mysqli_close($db_handle);
Ejemplo n.º 2
0
    $sql = "INSERT INTO `bluenet_v3`.`workers` (`id`, `ref_id`, `user_id`, `status`, `emergency_no`, `native_place`,\n\t\t\t\t\t\t\t\t`native_add`, `dob`, `education`, `experience`, `gender`, `remark`, `salary`, `local_id`)\n\t\t\t\tVALUES (NULL,\n\t\t\t\t\t'" . $refId . "',\n\t\t\t\t\t'" . $uwId . "',\n\t\t\t\t\t 'recruited',\n\t\t\t\t\t '" . $emergency_no . "',\n\t\t\t\t\t  '',\n\t\t\t\t\t   '" . $native_add . "',\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t '',\n\t\t\t\t\t\t '',\n\t\t\t\t\t\t  '',\n\t\t\t\t\t\t   '',\n\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t '" . $localId . "');";
    mysqli_query($db_handle, $sql);
    $wId = mysqli_insert_id($db_handle);
    //echo $wId. "\n";
    if ($wId == 0 || $wId == null) {
        echo " Error: " . mysqli_error($db_handle);
        die;
    }
    $sId = array('maid' => 1, 'cook' => 2, 'car cleaner' => 15);
    //5. adding worker service
    $sql = "INSERT INTO `bluenet_v3`.`service_worker_mappings`\n\t\t\t\t(`id`, `worker_id`, `service_id`)\n\t\t\t\t\tVALUES ('',\n\t\t\t\t\t'" . $wId . "',\n\t\t\t\t\t '" . $sId[$service] . "'\n\t\t\t\t\t );";
    mysqli_query($db_handle, $sql);
    //6. adding worker society mapping
    $sql = "INSERT INTO `bluenet_v3`.`society_worker_mapping`\n\t\t\t\t(`worker_id`, `society_id`)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'" . $wId . "',\n\t\t\t\t\t '" . $society . "'\n\t\t\t\t\t );";
    mysqli_query($db_handle, $sql);
    return $uwId;
}
function createDocUid($dbHandle, $uwId, $pvUid, $adharCardUid, $voterCardUid, $drivingLicenseUid, $panCardUid)
{
    $sql = "INSERT INTO `bluenet_v3`.`user_documents_uid` (`id`,  `user_id`, `pv_uid`, `adhar_card_uid`, `voter_id_uid`, `driving_license_uid`, `pan_card_uid`)\n\t\t\t\tVALUES (NULL,\n\t\t\t\t\t'" . $uwId . "',\n\t\t\t\t\t'" . $pvUid . "',\n\t\t\t\t\t '" . $adharCardUid . "',\n\t\t\t\t\t  '" . $voterCardUid . "',\n\t\t\t\t\t   '" . $drivingLicenseUid . "',\n\t\t\t\t\t\t'" . $panCardUid . "');";
    return mysqli_query($dbHandle, $sql);
}
$refId = createCustomer($db_handle, $input->root->resident_name, $input->root->resident_mobile, $input->root->resident_address, $route[2]);
if ($refId != 0) {
    $wId = createCustomerWorker($db_handle, $input->root->worker_name, $input->root->worker_mobile, $input->root->worker_address, $input->root->worker_photo, $refId, $input->root->worker_localId, $input->root->worker_service, $input->root->worker_pv, $input->root->worker_ac, $input->root->worker_vc, $input->root->worker_dl, $input->root->worker_pc, $input->root->worker_emergency_no, $input->root->worker_native_add, $route[2]);
    createDocUid($db_handle, $wId, $input->root->worker_pv_uid, $input->root->worker_ac_uid, $input->root->worker_vc_uid, $input->root->worker_dl_uid, $input->root->worker_pc_uid);
    //echo $refId." ".$wId.",";
    $input->root->resident_id = $refId;
    $input->root->worker_id = $wId;
}
print json_encode($input);