public function validasiDonasi($id)
 {
     $client = new Client(HelperController::getHost(), HelperController::getPort());
     $client->getTransport()->setAuth(HelperController::getUserNeo4j(), HelperController::getPassNeo4j());
     $status = 'failed';
     if (count($id) > 0) {
         $nodes = $client->getRelationship($id);
         $properties = array();
         if (count($nodes) > 0) {
             $donaturId = $nodes->getProperty('donaturId');
             $nodeDonatur = $client->getNode($donaturId);
             $gcmId = $nodeDonatur->getProperty('gcmId');
             $status = 'success';
             $nodes->setProperty('isValidate', 1)->save();
             $mustahiqId = $nodes->getProperty('mustahiqId');
             $nodeMustahiq = $client->getNode($mustahiqId);
             $imagePathMustahiq = $nodeMustahiq->getProperty('imagePath');
             $namaMustahiq = $nodeMustahiq->getProperty('nama');
             $nominal = $nodeMustahiq->getProperty('nominal');
             $datenow = date('Y-m-d H:i:s');
             NotifikasiController::createNotifikasiNode($donaturId, $mustahiqId, $namaMustahiq, $datenow, $imagePathMustahiq, $nominal, 'validasidonasi');
             GCMController::gcmPushNotifikasi('validasidonasi', $gcmId);
         } else {
             $status = 'failed, return value is empty check your donasi id';
         }
     } else {
         $status = 'failed, donasi id is empty';
     }
     return response()->json(array('status' => $status));
 }
Пример #2
0
 public function createDonasi(Request $request)
 {
     $client = new Client(HelperController::getHost(), HelperController::getPort());
     $client->getTransport()->setAuth(HelperController::getUserNeo4j(), HelperController::getPassNeo4j());
     $donaturId = $request->input('donaturId');
     $mustahiqId = $request->input('mustahiqId');
     $jenisDonasi = $request->input('jenisDonasi');
     $nama = $request->input('nama');
     $nominal = $request->input('nominal');
     $bank = $request->input('bank');
     $norek = $request->input('norek');
     $namaPengirim = $request->input('namaPengirim');
     $lazis = $request->input('lazis');
     $namaBarang = $request->input('namaBarang');
     $alamat = $request->input('alamat');
     $tglJemput = $request->input('tglJemput');
     $waktu = $request->input('waktu');
     $status = 'failed';
     $datenow = date('Y-m-d H:i:s');
     if (count($donaturId) > 0 && count($mustahiqId) > 0) {
         $donatur = $client->getNode($donaturId);
         $mustahiq = $client->getNode($mustahiqId);
         if (count($donatur) > 0 && count($mustahiq) > 0) {
             $imagePath = '';
             //image upload handler
             if ($jenisDonasi == 1) {
                 $image = $request->input('imagePath');
                 $imagePath = HelperController::saveImageWithReturn($image, 'donasi');
             }
             //proses edit persentasi dan jumlah penolong
             $node = $client->getNode($mustahiqId);
             $jumlahPenolong = $node->getProperty('jumlahPenolong');
             $persentaseBantuan = $node->getProperty('persentaseBantuan');
             $nominalBantuan = $node->getProperty('nominal');
             $jumlahPenolong++;
             $persentase = $nominal / $nominalBantuan * 100;
             $persentaseBantuan = $persentaseBantuan + $persentase;
             $node->setProperty('jumlahPenolong', $jumlahPenolong)->setProperty('persentaseBantuan', $persentaseBantuan)->save();
             // proses untuk menambahkan relasi donatur ke mustahiq
             $donatur->relateTo($mustahiq, 'DONASI')->setProperty('tanggal', $datenow)->setProperty('nama', $nama)->setProperty('donaturId', $donaturId)->setProperty('mustahiqId', $mustahiqId)->setProperty('nominal', $nominal)->setProperty('bank', $bank)->setProperty('norek', $norek)->setProperty('namaPengirim', $namaPengirim)->setProperty('lazis', $lazis)->setProperty('namaBarang', $namaBarang)->setProperty('alamat', $alamat)->setProperty('tglJemput', $tglJemput)->setProperty('waktu', $waktu)->setProperty('imagePath', $imagePath)->setProperty('isValidate', 0)->save();
             $status = 'success';
             $datenow = date('Y-m-d H:i:s');
             $imagePathMustahiq = $mustahiq->getProperty('imagePath');
             $namaMustahiq = $mustahiq->getProperty('nama');
             NotifikasiController::createNotifikasiNode($donaturId, $mustahiqId, $namaMustahiq, $datenow, $imagePathMustahiq, $nominal, 'donasi');
             //push notification
             $gcmId = $donatur->getProperty('gcmId');
             GCMController::gcmPushNotifikasi('donasi', $gcmId);
         } else {
             $status = 'failed, return value is empty check your donatur or mustahiq id';
         }
     } else {
         $status = 'failed, donatur or mustahiq id is empty';
     }
     return response()->json(array('status' => $status));
 }
 public function createMustahiq(Request $request)
 {
     $client = new Client(HelperController::getHost(), HelperController::getPort());
     $client->getTransport()->setAuth(HelperController::getUserNeo4j(), HelperController::getPassNeo4j());
     $nama = $request->input('nama');
     $desc = $request->input('desc');
     $tempatLahir = $request->input('tempatLahir');
     $tanggalLahir = $request->input('tanggalLahir');
     $nominal = $request->input('nominal');
     $alamat = $request->input('alamat');
     $latlong = $request->input('latlong');
     $status = $request->input('status');
     $jenjangPendidikan = $request->input('jenjangPendidikan');
     $asalSekolah = $request->input('asalSekolah');
     $alamatSekolah = $request->input('alamatSekolah');
     $namaOrangTua = $request->input('namaOrangTua');
     $alamatOrangTua = $request->input('alamatOrangTua');
     $pekerjaanOrangTua = $request->input('pekerjaanOrangTua');
     $kategori = $request->input('kategori');
     $donaturId = $request->input('donaturId');
     $tahunLahir = $request->input('tahunLahir');
     $persentaseBantuan = 0;
     $jumlahPenolong = 0;
     $prioritas = 0;
     $isApproved = 'NO';
     $statusRequest = 'failed';
     if (count($nama) > 0 && count($latlong) > 0 && count($donaturId) > 0) {
         $nodeDonatur = $client->getNode($donaturId);
         if (count($nodeDonatur) > 0) {
             if (count($nodeDonatur->getProperties()) > 0) {
                 $labels = $nodeDonatur->getLabels();
                 $label = $labels[0]->getName();
                 $gcmId = $nodeDonatur->getProperty('gcmId');
                 if ($label == HelperController::getLabelDonatur()) {
                     //image upload handler
                     $image = $request->input('imagePath');
                     $imagePath = HelperController::saveImageWithReturn($image, 'mustahiq');
                     $cypher = 'CREATE (n:' . HelperController::getLabelMustahiq() . ' {nama:"' . $nama . '",desc:"' . $desc . '"
           ,tempatLahir:"' . $tempatLahir . '",tanggalLahir:"' . $tanggalLahir . '",nominal:' . $nominal . '
           ,alamat:"' . $alamat . '",latlong:"' . $latlong . '",status:"' . $status . '",jenjangPendidikan:"' . $jenjangPendidikan . '"
           ,asalSekolah:"' . $asalSekolah . '",alamatSekolah:"' . $alamatSekolah . '",namaOrangTua:"' . $namaOrangTua . '",alamatOrangTua:"' . $alamatOrangTua . '"
           ,pekerjaanOrangTua:"' . $pekerjaanOrangTua . '",kategori:"' . $kategori . '",persentaseBantuan:' . $persentaseBantuan . '
           ,prioritas:' . $prioritas . ',imagePath:"' . $imagePath . '",isApproved:"' . $isApproved . '"
           ,tahunLahir:' . $tahunLahir . ',jumlahPenolong:' . $jumlahPenolong . ',donaturId:' . $donaturId . '}) return n';
                     $query = new Query($client, $cypher);
                     $nodes = $query->getResultSet();
                     // add mustahiq relationship
                     $datenow = date('Y-m-d H:i:s');
                     $mustahiqId = 0;
                     foreach ($nodes as $node) {
                         $mustahiqId = $node['n']->getId();
                     }
                     $donatur = $client->getNode($donaturId);
                     $mustahiq = $client->getNode($mustahiqId);
                     $donatur->relateTo($mustahiq, 'RECOMMENDED')->setProperty('tanggal', $datenow)->save();
                     $statusRequest = 'success';
                     NotifikasiController::createNotifikasiNode($donaturId, $mustahiqId, $nama, $datenow, $imagePath, -1, 'rekomendasi');
                     GCMController::gcmPushNotifikasi('rekomendasi', $gcmId);
                 } else {
                     $statusRequest = 'failed, the label is not donatur check your parameter';
                 }
             } else {
                 $statusRequest = 'failed, the label is not donatur check your parameter';
             }
         } else {
             $statusRequest = 'failed, return value is empty check your donatur id';
         }
     } else {
         $statusRequest = 'failed, please check your parameter';
     }
     return response()->json(array('status' => $statusRequest));
 }